@alexsun-top/opencode-chat-room 0.7.0 → 0.7.2
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 +24 -0
- package/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/package.json +1 -1
- package/server/assets/base.css +4 -1
- package/server/assets/chat/create-room-dialog.js +49 -0
- package/server/assets/chat/editor.js +28 -9
- package/server/assets/chat/events.js +41 -23
- package/server/assets/chat/history-loader.js +1 -0
- package/server/assets/chat/image-zoom.js +49 -16
- package/server/assets/chat/index.js +2 -0
- package/server/assets/chat/locales/de.js +6 -2
- package/server/assets/chat/locales/es.js +6 -2
- package/server/assets/chat/locales/fr.js +6 -2
- package/server/assets/chat/locales/it.js +6 -2
- package/server/assets/chat/locales/ja.js +6 -2
- package/server/assets/chat/locales/ko.js +6 -2
- package/server/assets/chat/markdown.js +7 -1
- package/server/assets/chat/members.js +2 -0
- package/server/assets/chat/messages.js +1 -0
- package/server/assets/chat/questions.js +1 -0
- package/server/assets/chat/room-list.js +9 -1
- package/server/assets/chat/rooms.js +23 -9
- package/server/assets/chat/settings.js +40 -1
- package/server/assets/chat/shortcuts.js +137 -14
- package/server/assets/chat/state.js +14 -6
- package/server/assets/chat/viewport.js +3 -0
- package/server/assets/conversation.css +22 -19
- package/server/assets/responsive.css +52 -0
- package/server/assets/room-create.css +86 -0
- package/server/assets/settings.css +93 -35
- package/server/chat-server.ts +3 -3
- package/server/chat.html +138 -72
- package/server/sw.js +1 -0
- package/skills/chatroom/SKILL.md +2 -1
package/server/chat.html
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
<link rel="stylesheet" href="/assets/attachments.css">
|
|
27
27
|
<link rel="stylesheet" href="/assets/responsive.css">
|
|
28
28
|
<link rel="stylesheet" href="/assets/code-highlight.css">
|
|
29
|
+
<link rel="stylesheet" href="/assets/room-create.css">
|
|
29
30
|
</head>
|
|
30
31
|
<body>
|
|
31
32
|
|
|
@@ -127,68 +128,112 @@
|
|
|
127
128
|
|
|
128
129
|
<!-- One settings surface for the join page and the signed-in chat. -->
|
|
129
130
|
<dialog id="chatSettings" class="settings-dialog" aria-labelledby="settingsHeading">
|
|
130
|
-
<
|
|
131
|
-
<
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
<
|
|
139
|
-
<
|
|
140
|
-
<
|
|
141
|
-
<
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
<
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
<
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
</
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
131
|
+
<header class="settings-head">
|
|
132
|
+
<div class="settings-heading">
|
|
133
|
+
<h2 id="settingsHeading" tabindex="-1" data-i18n="settings">Settings</h2>
|
|
134
|
+
<p class="settings-lead" data-i18n="settingsLocalHint">Language, theme, transition, and scrolling preferences are saved in this browser.</p>
|
|
135
|
+
</div>
|
|
136
|
+
<button id="btnCloseSettings" class="reader-close settings-close" type="button" aria-label="Close" data-i18n-aria-label="close"><svg class="close-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M6 6l12 12M18 6 6 18"/></svg></button>
|
|
137
|
+
</header>
|
|
138
|
+
<div class="settings-body">
|
|
139
|
+
<nav class="settings-nav" role="tablist" aria-label="Settings sections" data-i18n-aria-label="settingsSections">
|
|
140
|
+
<button id="settingsTabGeneral" class="settings-tab" type="button" role="tab" aria-selected="true" aria-controls="settingsPanelGeneral" data-settings-tab="general">
|
|
141
|
+
<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M4 7h9M17 7h3M4 17h3M11 17h9"/><circle cx="15" cy="7" r="2"/><circle cx="9" cy="17" r="2"/></svg>
|
|
142
|
+
<span data-i18n="settingsGeneral">General</span>
|
|
143
|
+
</button>
|
|
144
|
+
<button id="settingsTabAppearance" class="settings-tab" type="button" role="tab" aria-selected="false" aria-controls="settingsPanelAppearance" tabindex="-1" data-settings-tab="appearance">
|
|
145
|
+
<svg aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"/><path d="M12 4v16"/><path d="M12 4a8 8 0 0 1 0 16" fill="currentColor" stroke="none"/></svg>
|
|
146
|
+
<span data-i18n="settingsAppearance">Appearance</span>
|
|
147
|
+
</button>
|
|
148
|
+
<button id="settingsTabConnection" class="settings-tab" type="button" role="tab" aria-selected="false" aria-controls="settingsPanelConnection" tabindex="-1" data-settings-tab="connection">
|
|
149
|
+
<svg aria-hidden="true" viewBox="0 0 24 24"><circle cx="8" cy="12" r="3"/><path d="M11 12h9M17 12v3M20 12v2"/></svg>
|
|
150
|
+
<span data-i18n="settingsConnection">Connection</span>
|
|
151
|
+
</button>
|
|
152
|
+
</nav>
|
|
153
|
+
<div class="settings-content">
|
|
154
|
+
<section id="settingsPanelGeneral" class="settings-panel" role="tabpanel" aria-labelledby="settingsTabGeneral">
|
|
155
|
+
<div class="settings-row">
|
|
156
|
+
<div class="settings-copy">
|
|
157
|
+
<label class="settings-label locale-label" for="localeSelectSettings">
|
|
158
|
+
<svg class="locale-icon" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c2.5 2.7 3.8 5.7 3.8 9S14.5 18.3 12 21M12 3C9.5 5.7 8.2 8.7 8.2 12s1.3 6.3 3.8 9"/></svg>
|
|
159
|
+
<span data-i18n="languageLabel">Language</span>
|
|
160
|
+
</label>
|
|
161
|
+
<p class="settings-hint" data-i18n="settingsLanguageHint">Applies right away and is saved in this browser.</p>
|
|
162
|
+
</div>
|
|
163
|
+
<select id="localeSelectSettings" class="locale-select settings-select">
|
|
164
|
+
<option value="en">English</option>
|
|
165
|
+
<option value="zh-CN">中文</option>
|
|
166
|
+
<option value="ja">日本語</option>
|
|
167
|
+
<option value="ko">한국어</option>
|
|
168
|
+
<option value="fr">Français</option>
|
|
169
|
+
<option value="de">Deutsch</option>
|
|
170
|
+
<option value="es">Español</option>
|
|
171
|
+
<option value="it">Italiano</option>
|
|
172
|
+
</select>
|
|
173
|
+
</div>
|
|
174
|
+
<div class="settings-row">
|
|
175
|
+
<div class="settings-copy">
|
|
176
|
+
<label class="settings-label" for="inContentTransition" data-i18n="contentTransition">Room content transition</label>
|
|
177
|
+
<p id="contentTransitionHint" class="settings-hint" data-i18n="contentTransitionHint">Slide messages in when switching rooms with Alt+Arrow. Off by default.</p>
|
|
178
|
+
</div>
|
|
179
|
+
<input id="inContentTransition" class="settings-switch" type="checkbox" role="switch" aria-describedby="contentTransitionHint">
|
|
180
|
+
</div>
|
|
181
|
+
<div class="settings-row">
|
|
182
|
+
<div class="settings-copy">
|
|
183
|
+
<label class="settings-label" for="inPageStep" data-i18n="pageStep">Page scroll distance</label>
|
|
184
|
+
<p id="pageStepHint" class="settings-hint" data-i18n="pageStepHint">How far PageUp and PageDown move per press, as a percentage of the conversation height. Default 90%.</p>
|
|
185
|
+
</div>
|
|
186
|
+
<div class="settings-number"><input id="inPageStep" class="input" type="number" min="20" max="200" step="5" inputmode="numeric" value="90" aria-describedby="pageStepHint"><span class="settings-number-unit" aria-hidden="true">%</span></div>
|
|
187
|
+
</div>
|
|
188
|
+
</section>
|
|
189
|
+
<section id="settingsPanelAppearance" class="settings-panel" role="tabpanel" aria-labelledby="settingsTabAppearance" hidden>
|
|
190
|
+
<fieldset class="settings-block">
|
|
191
|
+
<legend class="settings-label" data-i18n="themeLabel">Theme</legend>
|
|
192
|
+
<p class="settings-hint" data-i18n="settingsThemeHint">Saved in this browser. System follows your device.</p>
|
|
193
|
+
<div class="theme-grid">
|
|
194
|
+
<label class="theme-option" data-theme-choice="system">
|
|
195
|
+
<input type="radio" name="theme" value="system">
|
|
196
|
+
<span class="theme-preview" aria-hidden="true"></span>
|
|
197
|
+
<span class="theme-name" data-i18n="themeSystem">System</span>
|
|
198
|
+
</label>
|
|
199
|
+
<label class="theme-option" data-theme-choice="light">
|
|
200
|
+
<input type="radio" name="theme" value="light">
|
|
201
|
+
<span class="theme-preview" aria-hidden="true"></span>
|
|
202
|
+
<span class="theme-name" data-i18n="themeLight">Light</span>
|
|
203
|
+
</label>
|
|
204
|
+
<label class="theme-option" data-theme-choice="dark">
|
|
205
|
+
<input type="radio" name="theme" value="dark">
|
|
206
|
+
<span class="theme-preview" aria-hidden="true"></span>
|
|
207
|
+
<span class="theme-name" data-i18n="themeDark">Dark</span>
|
|
208
|
+
</label>
|
|
209
|
+
<label class="theme-option" data-theme-choice="forest">
|
|
210
|
+
<input type="radio" name="theme" value="forest">
|
|
211
|
+
<span class="theme-preview" aria-hidden="true"></span>
|
|
212
|
+
<span class="theme-name" data-i18n="themeForest">Forest</span>
|
|
213
|
+
</label>
|
|
214
|
+
<label class="theme-option" data-theme-choice="sand">
|
|
215
|
+
<input type="radio" name="theme" value="sand">
|
|
216
|
+
<span class="theme-preview" aria-hidden="true"></span>
|
|
217
|
+
<span class="theme-name" data-i18n="themeSand">Sand</span>
|
|
218
|
+
</label>
|
|
219
|
+
</div>
|
|
220
|
+
</fieldset>
|
|
221
|
+
</section>
|
|
222
|
+
<section id="settingsPanelConnection" class="settings-panel" role="tabpanel" aria-labelledby="settingsTabConnection" hidden>
|
|
223
|
+
<div class="settings-row settings-row-stack">
|
|
224
|
+
<div class="settings-copy">
|
|
225
|
+
<label class="settings-label" for="inTokenChat" data-i18n="tokenOptional">Access token (optional)</label>
|
|
226
|
+
<p class="settings-hint" data-i18n="settingsTokenHint">Stored only in this browser. Needed only when the server asks for it.</p>
|
|
227
|
+
<p id="tokenHint" class="settings-hint settings-warning" data-i18n="tokenRequired" hidden>The server requires an access token (401).</p>
|
|
228
|
+
</div>
|
|
229
|
+
<div class="settings-token-control">
|
|
230
|
+
<input id="inTokenChat" class="input" type="password" placeholder="Enter if the server requires it" data-i18n-placeholder="tokenPlaceholder" autocomplete="off" spellcheck="false" aria-describedby="tokenHint">
|
|
231
|
+
<button class="btn ghost small" type="button" data-token-save="inTokenChat" data-i18n="save">Save</button>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
<p class="settings-note" data-i18n="privacyNote">Anyone with the shared token can read direct messages and manage rooms; the server can read them too.</p>
|
|
235
|
+
</section>
|
|
236
|
+
</div>
|
|
192
237
|
</div>
|
|
193
238
|
</dialog>
|
|
194
239
|
|
|
@@ -196,16 +241,7 @@
|
|
|
196
241
|
<section id="chatView" class="view" hidden>
|
|
197
242
|
<aside id="roomRail" class="room-rail" aria-label="Rooms" data-i18n-aria-label="roomsLabel">
|
|
198
243
|
<div class="rail-brand"><span class="brand-mark">OC</span><span data-i18n="brand">OC Chat</span><span class="version-tag">{{version}}</span></div>
|
|
199
|
-
<div class="rail-label"><span data-i18n="existingRooms">Rooms</span><span class="rail-tools"><button id="btnNewRoom" class="icon-btn" type="button" aria-label="Create a room" data-i18n-aria-label="newRoom"><svg aria-hidden="true" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></svg></button><button id="btnRefreshRooms" class="icon-btn" type="button" aria-label="Refresh rooms" data-i18n-aria-label="refreshRooms"><svg aria-hidden="true" viewBox="0 0 24 24"><path d="M20 7v5h-5M4 17v-5h5"/><path d="M5.6 9a7 7 0 0 1 11.8-2L20 12M4 12l2.6 5a7 7 0 0 0 11.8-2"/></svg></button></span></div>
|
|
200
|
-
<form id="railRoomForm" class="rail-composer" hidden>
|
|
201
|
-
<label class="field"><span class="field-label" data-i18n="newRoomNameLabel">New room name</span><input id="inRoomNameChat" class="input" maxlength="40" data-i18n-placeholder="newRoomNamePlaceholder" placeholder="e.g. Weekend movie night"></label>
|
|
202
|
-
<div class="join-policy rail-join-policy">
|
|
203
|
-
<input id="inApprovalRequiredChat" type="checkbox" role="switch" aria-describedby="inApprovalRequiredChatHint">
|
|
204
|
-
<label for="inApprovalRequiredChat" class="join-policy-label" data-i18n="requireApproval">Require approval to join</label>
|
|
205
|
-
</div>
|
|
206
|
-
<p id="inApprovalRequiredChatHint" class="hint join-policy-hint rail-join-policy-hint" data-i18n="requireApprovalHint">New members need a human administrator's approval. Agents may also be approved by the administrator agent.</p>
|
|
207
|
-
<button id="btnCreateChatRoom" class="btn primary small" type="submit" data-i18n="createRoom">Create room</button>
|
|
208
|
-
</form>
|
|
244
|
+
<div class="rail-label"><span data-i18n="existingRooms">Rooms</span><span class="rail-tools"><button id="btnNewRoom" class="icon-btn" type="button" aria-label="Create a room" data-i18n-aria-label="newRoom" aria-haspopup="dialog" aria-controls="createRoomDialog" aria-expanded="false"><svg aria-hidden="true" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></svg></button><button id="btnRefreshRooms" class="icon-btn" type="button" aria-label="Refresh rooms" data-i18n-aria-label="refreshRooms"><svg aria-hidden="true" viewBox="0 0 24 24"><path d="M20 7v5h-5M4 17v-5h5"/><path d="M5.6 9a7 7 0 0 1 11.8-2L20 12M4 12l2.6 5a7 7 0 0 0 11.8-2"/></svg></button></span></div>
|
|
209
245
|
<ul id="roomListChat" class="rail-rooms"></ul>
|
|
210
246
|
<p id="roomListChatEmpty" class="hint" data-i18n="noRooms" hidden></p>
|
|
211
247
|
|
|
@@ -221,6 +257,35 @@
|
|
|
221
257
|
</div>
|
|
222
258
|
</div>
|
|
223
259
|
</aside>
|
|
260
|
+
<dialog id="createRoomDialog" class="admin-dialog create-room-dialog" aria-labelledby="createRoomHeading" aria-describedby="createRoomHint">
|
|
261
|
+
<header class="create-room-head">
|
|
262
|
+
<span class="create-room-mark" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></svg></span>
|
|
263
|
+
<div class="create-room-heading">
|
|
264
|
+
<p class="create-room-eyebrow" data-i18n="existingRooms">Rooms</p>
|
|
265
|
+
<h2 id="createRoomHeading" data-i18n="createRoomTitle">Create a room</h2>
|
|
266
|
+
</div>
|
|
267
|
+
<button id="btnCloseCreateRoom" class="reader-close" type="button" aria-label="Close" data-i18n-aria-label="close"><svg class="close-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M6 6l12 12M18 6 6 18"/></svg></button>
|
|
268
|
+
</header>
|
|
269
|
+
<p id="createRoomHint" class="create-room-hint" data-i18n="createRoomHint">Start a new room and invite people with its ID.</p>
|
|
270
|
+
<form id="railRoomForm" class="create-room-form" novalidate>
|
|
271
|
+
<label class="field create-room-field">
|
|
272
|
+
<span class="field-label" data-i18n="newRoomNameLabel">New room name</span>
|
|
273
|
+
<input id="inRoomNameChat" class="input create-room-input" maxlength="40" data-i18n-placeholder="newRoomNamePlaceholder" placeholder="e.g. Weekend movie night" autocomplete="off">
|
|
274
|
+
</label>
|
|
275
|
+
<div class="create-room-policy">
|
|
276
|
+
<div class="join-policy">
|
|
277
|
+
<input id="inApprovalRequiredChat" type="checkbox" role="switch" aria-describedby="inApprovalRequiredChatHint">
|
|
278
|
+
<label for="inApprovalRequiredChat" class="join-policy-label" data-i18n="requireApproval">Require approval to join</label>
|
|
279
|
+
</div>
|
|
280
|
+
<p id="inApprovalRequiredChatHint" class="hint create-room-policy-hint" data-i18n="requireApprovalHint">New members need a human administrator's approval. Agents may also be approved by the administrator agent.</p>
|
|
281
|
+
</div>
|
|
282
|
+
<p id="createRoomError" class="alert create-room-error" role="alert" hidden></p>
|
|
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>
|
|
286
|
+
</div>
|
|
287
|
+
</form>
|
|
288
|
+
</dialog>
|
|
224
289
|
<dialog id="editRoomDialog" class="admin-dialog" aria-labelledby="editRoomHeading">
|
|
225
290
|
<header class="admin-dialog-head"><h2 id="editRoomHeading" data-i18n="editRoom">Edit room</h2><div class="admin-dialog-actions"><button id="btnCloseEditRoom" class="reader-close" type="button" aria-label="Close" data-i18n-aria-label="close"><svg class="close-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M6 6l12 12M18 6 6 18"/></svg></button></div></header>
|
|
226
291
|
<p id="editRoomStatus" class="hint" role="status" aria-live="polite"></p>
|
|
@@ -441,6 +506,7 @@
|
|
|
441
506
|
<h3 data-i18n="shortcutsRooms">Rooms</h3>
|
|
442
507
|
<ul class="keys-list">
|
|
443
508
|
<li><span class="keys-combo"><kbd class="keys-key shortcut-mod">Alt</kbd><span class="keys-sep">+</span><kbd class="keys-key">↑</kbd><span class="keys-sep">/</span><kbd class="keys-key">↓</kbd></span><span data-i18n="shortcutsSwitchRoom">Switch to the previous or next room</span></li>
|
|
509
|
+
<li><span class="keys-combo"><kbd class="keys-key shortcut-mod">Alt</kbd><span class="keys-sep">+</span><kbd class="keys-key">1–9</kbd></span><span data-i18n="shortcutsNumberRoom">Switch to a joined room by number</span></li>
|
|
444
510
|
</ul>
|
|
445
511
|
</section>
|
|
446
512
|
<section class="keys-section">
|
package/server/sw.js
CHANGED
package/skills/chatroom/SKILL.md
CHANGED
|
@@ -49,13 +49,14 @@ Discuss shared questions in the room rather than opening private dialogs. Consol
|
|
|
49
49
|
|
|
50
50
|
- Do not join any room unless the user explicitly asks you to join it. A notification, mention, room ID, or another agent's invitation is not permission to join. When authorized, provide an explicit non-empty `name`.
|
|
51
51
|
- For `join`, `name` is your own participant display name, not the room name. Use `roomId` to identify the room. For example, to join room `project-alpha` as `reviewer`, pass `{"action":"join","roomId":"<project-alpha-room-id>","name":"reviewer"}`. For `create`, `name` is the new room's name instead.
|
|
52
|
+
- To rename yourself in a room, `leave` it and `join` it again with the new `name`. Earlier messages keep their original author name; in an approval room, rejoining may return pending until an administrator approves it.
|
|
52
53
|
- Use `send` for messages, `poll` for full messages when needed, and `leave` to exit. A truncated preview is not the full message.
|
|
53
54
|
- Address the intended participant in the message text; use room broadcasts only for genuinely shared work.
|
|
54
55
|
- Shared room tokens grant room access and management. A direct conversation is not private from other token holders.
|
|
55
56
|
|
|
56
57
|
## Protected rooms
|
|
57
58
|
|
|
58
|
-
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. 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, 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
60
|
|
|
60
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.
|
|
61
62
|
|