@alexsun-top/opencode-chat-room 0.8.2 → 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.
Files changed (92) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +18 -62
  3. package/README.zh-CN.md +25 -69
  4. package/dist/cli.js +466 -188
  5. package/package.json +8 -5
  6. package/packages/chat-room-channeld/README.md +25 -3
  7. package/packages/chat-room-channeld/dist/mock-adapter.js +5 -5
  8. package/packages/chat-room-channeld/src/adapter.ts +5 -0
  9. package/packages/chat-room-channeld/src/cli.ts +72 -5
  10. package/packages/chat-room-channeld/src/host.ts +17 -2
  11. package/packages/chat-room-channeld/src/pg/database.ts +187 -0
  12. package/packages/chat-room-channeld/src/pg/migrate.ts +150 -0
  13. package/packages/chat-room-channeld/src/pg/schema.ts +60 -0
  14. package/packages/chat-room-channeld/src/pg/sql.mjs +175 -0
  15. package/packages/chat-room-channeld/src/pg/sqlite.ts +100 -0
  16. package/packages/chat-room-channeld/src/pg/worker.mjs +133 -0
  17. package/packages/chat-room-channeld/src/protocol.ts +1 -0
  18. package/packages/chat-room-channeld/src/state.ts +73 -97
  19. package/packages/chat-room-channeld/src/stats.ts +140 -109
  20. package/server/assets/base.css +3 -1
  21. package/server/assets/chat/admin-badge.js +32 -30
  22. package/server/assets/chat/admin.js +198 -161
  23. package/server/assets/chat/announcements.js +295 -208
  24. package/server/assets/chat/attachment-store.js +106 -75
  25. package/server/assets/chat/attachments.js +686 -441
  26. package/server/assets/chat/chat-background.js +185 -156
  27. package/server/assets/chat/clipboard.js +44 -25
  28. package/server/assets/chat/confirm-dialog.js +36 -33
  29. package/server/assets/chat/copy-action.js +40 -40
  30. package/server/assets/chat/create-room-dialog.js +50 -47
  31. package/server/assets/chat/diagram-viewer.js +293 -234
  32. package/server/assets/chat/doc-preview.js +507 -441
  33. package/server/assets/chat/editor.js +423 -335
  34. package/server/assets/chat/events.js +637 -510
  35. package/server/assets/chat/files.js +476 -430
  36. package/server/assets/chat/history-loader.js +79 -73
  37. package/server/assets/chat/icons.js +9 -11
  38. package/server/assets/chat/image-zoom.js +239 -176
  39. package/server/assets/chat/index.js +2 -3
  40. package/server/assets/chat/install-prompt.js +86 -66
  41. package/server/assets/chat/integration-account-schema.js +88 -86
  42. package/server/assets/chat/integration-editor.js +162 -153
  43. package/server/assets/chat/integration-values.js +109 -100
  44. package/server/assets/chat/integrations.js +689 -622
  45. package/server/assets/chat/join-requests.js +408 -358
  46. package/server/assets/chat/locales/de.js +193 -194
  47. package/server/assets/chat/locales/es.js +193 -194
  48. package/server/assets/chat/locales/fr.js +193 -194
  49. package/server/assets/chat/locales/index.js +1 -2
  50. package/server/assets/chat/locales/it.js +193 -194
  51. package/server/assets/chat/locales/ja.js +193 -193
  52. package/server/assets/chat/locales/ko.js +193 -193
  53. package/server/assets/chat/markdown-footnotes.js +134 -102
  54. package/server/assets/chat/markdown.js +547 -403
  55. package/server/assets/chat/members.js +236 -197
  56. package/server/assets/chat/mentions.js +157 -133
  57. package/server/assets/chat/message-cache.js +40 -33
  58. package/server/assets/chat/message-polling.js +280 -227
  59. package/server/assets/chat/message-window.js +74 -55
  60. package/server/assets/chat/messages.js +552 -480
  61. package/server/assets/chat/office-preview.js +46 -45
  62. package/server/assets/chat/palette.js +450 -417
  63. package/server/assets/chat/panels.js +94 -78
  64. package/server/assets/chat/pwa.js +144 -73
  65. package/server/assets/chat/questions.js +372 -302
  66. package/server/assets/chat/recall.js +320 -273
  67. package/server/assets/chat/receipts.js +149 -121
  68. package/server/assets/chat/reminders.js +331 -214
  69. package/server/assets/chat/replies.js +165 -130
  70. package/server/assets/chat/resource-format.js +59 -62
  71. package/server/assets/chat/room-list.js +58 -55
  72. package/server/assets/chat/room-watcher.js +72 -50
  73. package/server/assets/chat/rooms.js +623 -500
  74. package/server/assets/chat/search.js +136 -114
  75. package/server/assets/chat/settings.js +223 -200
  76. package/server/assets/chat/shiki.js +61 -62
  77. package/server/assets/chat/shortcuts.js +212 -187
  78. package/server/assets/chat/side-pane.js +160 -150
  79. package/server/assets/chat/state.js +849 -735
  80. package/server/assets/chat/system-events.js +45 -43
  81. package/server/assets/chat/system-messages.js +57 -56
  82. package/server/assets/chat/task-form.js +178 -182
  83. package/server/assets/chat/task-row.js +158 -155
  84. package/server/assets/chat/tasks.js +653 -587
  85. package/server/assets/chat/viewport.js +32 -29
  86. package/server/assets/chat/window-controls.js +32 -32
  87. package/server/assets/conversation.css +10 -4
  88. package/server/chat-server.ts +9 -1
  89. package/server/chat.html +2 -1
  90. package/server/routes/pages.ts +7 -5
  91. package/server/sw.js +346 -268
  92. package/src/web/integration-rules-editor.ts +2 -0
@@ -1,31 +1,34 @@
1
1
  // Keep the app inside the visible area when a soft keyboard opens (iOS does not resize the layout viewport).
2
2
  export function initViewport() {
3
- const root = document.documentElement;
4
- const viewport = window.visualViewport;
5
- if (!viewport) return;
6
- let lastHeight = viewport.height;
7
-
8
- // Pinch zoom shrinks visualViewport.height while the layout stays the same
9
- // size. Resizing the app then would collapse the whole UI under the fingers.
10
- const zoomed = () => Math.abs((viewport.scale || 1) - 1) > 0.01;
11
-
12
- const sync = () => {
13
- if (zoomed()) return;
14
- root.style.setProperty("--app-height", `${Math.round(viewport.height)}px`);
15
- if (viewport.height < lastHeight - 80 && document.activeElement?.id === "msgInput") {
16
- requestAnimationFrame(() => {
17
- const thread = document.querySelector("#thread");
18
- if (thread) thread.scrollTop = thread.scrollHeight;
19
- });
20
- }
21
- lastHeight = viewport.height;
22
- };
23
- viewport.addEventListener("resize", sync);
24
- viewport.addEventListener("scroll", sync);
25
- window.addEventListener("resize", sync);
26
- window.addEventListener("pageshow", sync);
27
- window.addEventListener("orientationchange", sync);
28
- document.addEventListener("visibilitychange", () => { if (!document.hidden) sync(); });
29
- sync();
30
- if (matchMedia("(pointer: coarse)").matches) document.querySelector("#msgInput")?.setAttribute("enterkeyhint", "enter");
31
- }
3
+ const root = document.documentElement;
4
+ const viewport = window.visualViewport;
5
+ if (!viewport)
6
+ return;
7
+ let lastHeight = viewport.height;
8
+ // Pinch zoom shrinks visualViewport.height while the layout stays the same
9
+ // size. Resizing the app then would collapse the whole UI under the fingers.
10
+ const zoomed = () => Math.abs((viewport.scale || 1) - 1) > 0.01;
11
+ const sync = () => {
12
+ if (zoomed())
13
+ return;
14
+ root.style.setProperty("--app-height", `${Math.round(viewport.height)}px`);
15
+ if (viewport.height < lastHeight - 80 && document.activeElement?.id === "msgInput") {
16
+ requestAnimationFrame(() => {
17
+ const thread = document.querySelector("#thread");
18
+ if (thread)
19
+ thread.scrollTop = thread.scrollHeight;
20
+ });
21
+ }
22
+ lastHeight = viewport.height;
23
+ };
24
+ viewport.addEventListener("resize", sync);
25
+ viewport.addEventListener("scroll", sync);
26
+ window.addEventListener("resize", sync);
27
+ window.addEventListener("pageshow", sync);
28
+ window.addEventListener("orientationchange", sync);
29
+ document.addEventListener("visibilitychange", () => { if (!document.hidden)
30
+ sync(); });
31
+ sync();
32
+ if (matchMedia("(pointer: coarse)").matches)
33
+ document.querySelector("#msgInput")?.setAttribute("enterkeyhint", "enter");
34
+ }
@@ -2,36 +2,36 @@
2
2
  // visible overlay gets the drag strip and titlebar inset; every other surface keeps
3
3
  // its normal layout with no dead drag area.
4
4
  const PROPS = ["top", "left", "width", "height"];
5
-
6
5
  export function initWindowControls() {
7
- const overlay = navigator.windowControlsOverlay;
8
- if (!overlay) return;
9
- const root = document.documentElement;
10
- let drag = null;
11
-
12
- const sync = () => {
13
- if (overlay.visible !== true) {
14
- delete root.dataset.wco;
15
- for (const name of PROPS) root.style.removeProperty(`--wco-${name}`);
16
- drag?.remove();
17
- drag = null;
18
- return;
19
- }
20
- // Real browsers resolve env(titlebar-area-*) first; the variables are a fallback
21
- // for browsers that expose the overlay without the CSS environment values.
22
- const area = overlay.getTitlebarAreaRect?.();
23
- if (area) {
24
- for (const name of PROPS) root.style.setProperty(`--wco-${name}`, `${area[name]}px`);
25
- }
26
- root.dataset.wco = "true";
27
- if (!drag) {
28
- drag = document.createElement("div");
29
- drag.className = "wco-drag";
30
- drag.setAttribute("aria-hidden", "true");
31
- document.body.append(drag);
32
- }
33
- };
34
-
35
- overlay.addEventListener("geometrychange", sync);
36
- sync();
37
- }
6
+ const overlay = navigator.windowControlsOverlay;
7
+ if (!overlay)
8
+ return;
9
+ const root = document.documentElement;
10
+ let drag = null;
11
+ const sync = () => {
12
+ if (overlay.visible !== true) {
13
+ delete root.dataset.wco;
14
+ for (const name of PROPS)
15
+ root.style.removeProperty(`--wco-${name}`);
16
+ drag?.remove();
17
+ drag = null;
18
+ return;
19
+ }
20
+ // Real browsers resolve env(titlebar-area-*) first; the variables are a fallback
21
+ // for browsers that expose the overlay without the CSS environment values.
22
+ const area = overlay.getTitlebarAreaRect?.();
23
+ if (area) {
24
+ for (const name of PROPS)
25
+ root.style.setProperty(`--wco-${name}`, `${area[name]}px`);
26
+ }
27
+ root.dataset.wco = "true";
28
+ if (!drag) {
29
+ drag = document.createElement("div");
30
+ drag.className = "wco-drag";
31
+ drag.setAttribute("aria-hidden", "true");
32
+ document.body.append(drag);
33
+ }
34
+ };
35
+ overlay.addEventListener("geometrychange", sync);
36
+ sync();
37
+ }
@@ -580,6 +580,8 @@
580
580
  }
581
581
  .sys[data-long="true"] .sys-event { border-radius: 12px; }
582
582
  .sys[data-kind="relay"] .sys-event { align-self: flex-start; border-radius: 12px; }
583
+ /* Decorative only: no chip, border, or hover chrome, so a notice never reads
584
+ as a clickable button. */
583
585
  .sys-icon {
584
586
  display: grid;
585
587
  place-items: center;
@@ -587,17 +589,21 @@
587
589
  width: 20px;
588
590
  height: 20px;
589
591
  margin-top: 1px;
590
- border-radius: 50%;
591
- color: var(--sys-accent);
592
- background: color-mix(in srgb, var(--sys-accent) 12%, transparent);
592
+ border: 0;
593
+ background: none;
594
+ color: var(--ink-3);
595
+ pointer-events: none;
593
596
  }
594
- .sys-icon-glyph { width: 13px; height: 13px; }
597
+ .sys-icon-glyph { width: 12px; height: 12px; }
595
598
  .sys-text { display: block; min-width: 0; overflow-wrap: anywhere; line-height: 1.45; }
596
599
  .sys-text > :first-child { margin-top: 0; }
597
600
  .sys-text > :last-child { margin-bottom: 0; }
598
601
  /* Date first and muted, matching relay messages. */
599
602
  .sys-time { order: -1; opacity: .72; }
600
603
  .sys-time { flex: none; color: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
604
+ /* Pill rows top-align the 11px date against a taller text line; center it on
605
+ the text's optical middle. Long cards and relay quotes keep the top edge. */
606
+ .sys:not([data-long="true"]):not([data-kind="relay"]) .sys-time { align-self: center; }
601
607
  .sys.recalled .sys-recalled {
602
608
  display: inline-flex;
603
609
  align-items: center;
@@ -12,12 +12,20 @@ import { wakeMentionedSessions } from "./wake.ts";
12
12
  const bootstrap = await loadServerBootstrap();
13
13
  // Set before the request handler runs; the controller reads its runtime lazily.
14
14
  let channels: ChannelController | undefined;
15
- const handle = createApp({
15
+ const serve = createApp({
16
16
  here: bootstrap.here,
17
17
  token: bootstrap.token,
18
18
  serveWakeUrl: bootstrap.serveWakeUrl,
19
19
  channeld: () => channels,
20
20
  });
21
+ // Test-only request accounting: asset hits prove whether a warm open re-downloaded.
22
+ const handle: typeof serve = process.env.CHAT_ROOM_TEST_ACCESS_LOG === "1"
23
+ ? (request) => {
24
+ const path = new URL(request.url).pathname;
25
+ if (path.startsWith("/assets/")) console.log(`[asset] ${path}`);
26
+ return serve(request);
27
+ }
28
+ : serve;
21
29
  const config = {
22
30
  hostname: bootstrap.hostname,
23
31
  port: bootstrap.port,
package/server/chat.html CHANGED
@@ -960,10 +960,11 @@
960
960
  <aside id="pwaUpdate" class="pwa-update" role="status" aria-live="polite" aria-labelledby="pwaUpdateTitle" hidden>
961
961
  <div class="pwa-update-copy">
962
962
  <strong id="pwaUpdateTitle" data-i18n="pwaUpdateTitle">Update available</strong>
963
- <p data-i18n="pwaUpdateBody">A new version is ready. Reload now, or update the next time you open the app.</p>
963
+ <p id="pwaUpdateBody" data-i18n="pwaUpdateBody">A new version is ready. Reload now, or update the next time you open the app.</p>
964
964
  </div>
965
965
  <div class="pwa-update-actions">
966
966
  <button id="btnPwaUpdate" class="btn primary small" type="button" data-i18n="pwaUpdateNow">Update now</button>
967
+ <button id="btnPwaRetry" class="btn primary small" type="button" data-i18n="pwaRetry" hidden>Retry</button>
967
968
  <button id="btnPwaLater" class="btn ghost small" type="button" data-i18n="pwaUpdateLater">Later</button>
968
969
  </div>
969
970
  </aside>
@@ -27,10 +27,12 @@ export async function pageRoutes(
27
27
  channeld: boolean,
28
28
  ): Promise<Response | undefined> {
29
29
  const p = url.pathname;
30
- if (req.method === "GET" && p === "/") {
30
+ // Head probes are read-only; they must not fall through to the JSON auth gate.
31
+ const read = req.method === "GET" || req.method === "HEAD";
32
+ if (read && p === "/") {
31
33
  return Response.redirect(new URL("/chat", url).toString(), 302);
32
34
  }
33
- if (req.method === "GET" && p === "/chat") {
35
+ if (read && p === "/chat") {
34
36
  const html = await fs
35
37
  .readFile(path.join(here, "chat.html"), "utf8")
36
38
  .catch(() => null);
@@ -48,14 +50,14 @@ export async function pageRoutes(
48
50
  });
49
51
  }
50
52
  // The install surface lives at the origin root so the worker controls /chat, not /assets.
51
- if (req.method === "GET" && p === "/manifest.webmanifest") {
53
+ if (read && p === "/manifest.webmanifest") {
52
54
  const body = await fs.readFile(path.join(here, "manifest.webmanifest"), "utf8").catch(() => null);
53
55
  if (body === null) return json({ error: "manifest not found" }, 404);
54
56
  return new Response(body, {
55
57
  headers: { "Content-Type": "application/manifest+json; charset=utf-8", "Cache-Control": "no-store" },
56
58
  });
57
59
  }
58
- if (req.method === "GET" && p === "/sw.js") {
60
+ if (read && p === "/sw.js") {
59
61
  const body = await fs.readFile(path.join(here, "sw.js"), "utf8").catch(() => null);
60
62
  if (body === null) return json({ error: "service worker not found" }, 404);
61
63
  const version = (await chatVersionTag(here)) || "dev";
@@ -67,7 +69,7 @@ export async function pageRoutes(
67
69
  },
68
70
  });
69
71
  }
70
- if (req.method === "GET" && p.startsWith("/assets/")) {
72
+ if (read && p.startsWith("/assets/")) {
71
73
  let relative: string;
72
74
  try { relative = decodeURIComponent(p.slice("/assets/".length)); }
73
75
  catch { return json({ error: "invalid asset path" }, 400); }