@alexsun-top/opencode-chat-room 0.8.1 → 0.8.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +10 -10
  3. package/README.zh-CN.md +10 -10
  4. package/dist/cli.js +544 -88
  5. package/package.json +4 -4
  6. package/packages/chat-room-channeld/README.md +17 -12
  7. package/packages/chat-room-channeld/src/adapter.ts +145 -7
  8. package/packages/chat-room-channeld/src/host.ts +24 -9
  9. package/packages/chat-room-channeld/src/inbound.ts +13 -4
  10. package/packages/chat-room-channeld/src/protocol.ts +52 -1
  11. package/packages/chat-room-channeld/src/rules.ts +7 -2
  12. package/plugin.ts +1 -1
  13. package/server/assets/base.css +8 -2
  14. package/server/assets/chat/admin.js +0 -2
  15. package/server/assets/chat/announcements.js +2 -4
  16. package/server/assets/chat/chat-background.js +177 -0
  17. package/server/assets/chat/confirm-dialog.js +0 -1
  18. package/server/assets/chat/create-room-dialog.js +0 -1
  19. package/server/assets/chat/diagram-viewer.js +7 -1
  20. package/server/assets/chat/doc-preview.js +71 -15
  21. package/server/assets/chat/events.js +13 -5
  22. package/server/assets/chat/files.js +10 -6
  23. package/server/assets/chat/image-zoom.js +8 -1
  24. package/server/assets/chat/index.js +4 -2
  25. package/server/assets/chat/integration-account-schema.js +99 -0
  26. package/server/assets/chat/integration-editor.js +1 -1
  27. package/server/assets/chat/integrations.js +207 -57
  28. package/server/assets/chat/locales/de.js +1 -1
  29. package/server/assets/chat/locales/es.js +1 -1
  30. package/server/assets/chat/locales/fr.js +1 -1
  31. package/server/assets/chat/locales/it.js +1 -1
  32. package/server/assets/chat/locales/ja.js +1 -1
  33. package/server/assets/chat/locales/ko.js +1 -1
  34. package/server/assets/chat/markdown-footnotes.js +1 -1
  35. package/server/assets/chat/markdown.js +23 -0
  36. package/server/assets/chat/messages.js +1 -0
  37. package/server/assets/chat/palette.js +6 -1
  38. package/server/assets/chat/panels.js +23 -3
  39. package/server/assets/chat/receipts.js +2 -3
  40. package/server/assets/chat/reminders.js +2 -4
  41. package/server/assets/chat/replies.js +0 -6
  42. package/server/assets/chat/rooms.js +1 -6
  43. package/server/assets/chat/settings.js +69 -3
  44. package/server/assets/chat/shortcuts.js +0 -3
  45. package/server/assets/chat/side-pane.js +33 -8
  46. package/server/assets/chat/state.js +48 -18
  47. package/server/assets/chat/system-events.js +29 -3
  48. package/server/assets/chat/system-messages.js +9 -0
  49. package/server/assets/chat/tasks.js +2 -8
  50. package/server/assets/chat/window-controls.js +37 -0
  51. package/server/assets/code-highlight.css +22 -6
  52. package/server/assets/conversation.css +55 -12
  53. package/server/assets/doc-preview.css +6 -1
  54. package/server/assets/files.css +3 -0
  55. package/server/assets/monaco/integration-rules.css +1 -1
  56. package/server/assets/monaco/integration-rules.js +841 -533
  57. package/server/assets/responsive.css +32 -2
  58. package/server/assets/settings.css +117 -13
  59. package/server/assets/window-controls.css +36 -0
  60. package/server/channel-attachments.ts +133 -0
  61. package/server/channel-integration.ts +79 -26
  62. package/server/channels.ts +15 -5
  63. package/server/chat.html +71 -37
  64. package/server/manifest.webmanifest +1 -0
  65. package/server/sw.js +1 -0
  66. package/src/center/center-client.ts +1 -1
  67. package/src/state/pg-database.ts +5 -5
  68. package/src/state/pg-migrate.ts +7 -7
  69. package/src/state/pg-worker.mjs +2 -17
  70. package/src/state/sqlite-database.ts +14 -5
  71. package/src/state/sqlite-rooms.ts +130 -23
  72. package/src/state/sqlite-state-store.ts +6 -5
  73. package/src/state/sqlite.ts +3 -3
  74. package/src/web/integration-rules-editor.ts +139 -5
  75. package/src/web/integration-rules.ts +6 -2
  76. package/src/web/integration-schema.ts +7 -6
  77. package/packages/chat-room-channeld/dist/feishu-adapter.js +0 -1262
  78. package/packages/chat-room-channeld/src/feishu-adapter.ts +0 -303
  79. package/packages/chat-room-channeld/src/feishu-card.ts +0 -27
  80. package/packages/chat-room-channeld/src/feishu-inbound.ts +0 -158
  81. package/packages/chat-room-channeld/src/feishu-live.ts +0 -355
  82. package/packages/chat-room-channeld/src/feishu-send.ts +0 -342
  83. package/packages/chat-room-channeld/src/feishu-ws-frames.ts +0 -173
  84. package/server/assets/chat/forward.js +0 -69
@@ -45,7 +45,7 @@ export function initReceipts(app) {
45
45
  if (selectedID && !event.target.closest("#readerPanel, .message-readers")) close(false);
46
46
  });
47
47
  document.addEventListener("keydown", (event) => {
48
- if (event.key === "Escape" && selectedID) { event.preventDefault(); close(true); }
48
+ if (event.key === "Escape" && !event.altKey && selectedID) { event.preventDefault(); close(true); }
49
49
  });
50
50
  window.addEventListener("resize", positionPanel);
51
51
  window.addEventListener("scroll", positionPanel, true);
@@ -54,7 +54,7 @@ export function initReceipts(app) {
54
54
  selectedID = id; trigger = button;
55
55
  button.setAttribute("aria-expanded", "true");
56
56
  panel.hidden = false; renderPanel(); positionPanel();
57
- requestAnimationFrame(() => $("#readerHeading").focus({ preventScroll: true }));
57
+ requestAnimationFrame(() => panel.focus({ preventScroll: true }));
58
58
  }
59
59
  function close(restoreFocus) {
60
60
  if (!selectedID) return;
@@ -84,7 +84,6 @@ export function initReceipts(app) {
84
84
  const message = app.state.room?.messages.find((item) => item.id === selectedID);
85
85
  if (!message) return close(false);
86
86
  const readers = readersFor(message);
87
- $("#readerHeading").textContent = app.t("readerPanelTitle");
88
87
  $("#readerCount").textContent = readerStatus(message, readers);
89
88
  const list = $("#readerList"); list.textContent = "";
90
89
  const members = app.state.memberSessions.get(app.state.room.id) || [];
@@ -184,11 +184,9 @@ export function initReminders(app) {
184
184
  newButton.addEventListener("click", () => openDialog());
185
185
  $("#btnCloseReminder").addEventListener("click", () => dialog.close());
186
186
  $("#btnCancelReminder").addEventListener("click", () => dialog.close());
187
- dialog.addEventListener("click", (event) => { if (event.target === dialog) dialog.close(); });
188
187
  dialog.addEventListener("close", () => { editing = null; });
189
188
  trigger.addEventListener("click", () => { app.closePanels(); openSurface(); });
190
189
  $("#btnCloseReminders").addEventListener("click", () => closeSurface());
191
- surface.addEventListener("click", (event) => { if (event.target === surface) closeSurface(); });
192
190
  surface.addEventListener("cancel", (event) => { event.preventDefault(); closeSurface(); });
193
191
  surface.addEventListener("close", () => {
194
192
  if (pendingReopen) { pendingReopen = false; return; }
@@ -200,12 +198,12 @@ export function initReminders(app) {
200
198
  if (focus && target?.isConnected) target.focus({ preventScroll: true });
201
199
  });
202
200
  document.addEventListener("keydown", (event) => {
203
- if (event.key !== "Escape" || !surface.open || !surface.classList.contains("is-pane")) return;
201
+ if (event.key !== "Escape" || event.altKey || !surface.open || !surface.classList.contains("is-pane")) return;
204
202
  if (!surface.contains(document.activeElement)) return;
205
203
  event.preventDefault();
206
204
  closeSurface();
207
205
  });
208
- app.registerPanelSurface?.("reminders", { close: () => closeSurface(false) });
206
+ app.registerPanelSurface?.("reminders", { element: surface, close: (restore = false) => closeSurface(restore) });
209
207
  app.watchPanel?.("reminders", syncMode);
210
208
  const closePanels = app.closePanels;
211
209
  app.closePanels = () => { closePanels(); if (dialog.open) dialog.close(); };
@@ -42,12 +42,6 @@ function bindMessageActions(app) {
42
42
  reply.type = "button"; reply.className = "message-reply"; reply.innerHTML = icon("arrow_reply", "message-reply-icon");
43
43
  reply.setAttribute("aria-label", app.t("replyMessage")); reply.dataset.i18nAriaLabel = "replyMessage"; reply.dataset.replyMessage = message.id;
44
44
  copy.before(actions); actions.append(copy, reply);
45
- if (document.body.dataset.channeld === "on") {
46
- const forward = document.createElement("button");
47
- forward.type = "button"; forward.className = "message-reply message-forward"; forward.innerHTML = icon("arrow_right", "message-reply-icon");
48
- forward.setAttribute("aria-label", app.t("forwardMessage")); forward.dataset.i18nAriaLabel = "forwardMessage"; forward.dataset.forwardMessage = message.id;
49
- actions.append(forward);
50
- }
51
45
  }
52
46
  return row;
53
47
  };
@@ -38,8 +38,6 @@ export function initRooms(app) {
38
38
  // A late restore must not steal the caret from someone already typing in the join form.
39
39
  const active = document.activeElement;
40
40
  if (!active || active === document.body || !active.closest?.("#joinView, dialog")) $("#inRoomId").focus();
41
- // First visit without a stored key: prompt once per tab instead of a dead page.
42
- if (!LS.token && !keyPromptDismissed()) app.openTokenBox();
43
41
  };
44
42
  app.showChat = () => {
45
43
  document.documentElement.classList.remove("session-restore");
@@ -503,10 +501,7 @@ async function bounded(items, limit, action) {
503
501
  }));
504
502
  }
505
503
 
506
- // A closed key prompt stays closed for this tab; a server refusal reopens it anyway.
507
- function keyPromptDismissed() {
508
- try { return sessionStorage.getItem("chat.keyPromptDismissed") === "1"; } catch { return false; }
509
- }
504
+
510
505
 
511
506
  function syncCachedRooms(rooms, app) {
512
507
  const remote = new Map(rooms.map((room) => [room.id, room]));
@@ -1,5 +1,15 @@
1
1
  // Browser settings shared by the join page and the chat: language, theme, window frame, and the optional token.
2
- export const THEMES = ["system", "light", "dark", "forest", "sand"];
2
+ export const THEMES = ["system", "light", "dark", "forest", "sand", "custom"];
3
+ const DEFAULT_CUSTOM_THEME = "#22695c";
4
+ const validColor = (value) => /^#[0-9a-f]{6}$/i.test(value) ? value : DEFAULT_CUSTOM_THEME;
5
+ // Relative luminance, so a dark choice gets the dark palette instead of dark text on it.
6
+ const isDarkColor = (color) => {
7
+ const channels = color.slice(1).match(/../g).map((part) => {
8
+ const value = parseInt(part, 16) / 255;
9
+ return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
10
+ });
11
+ return 0.2126 * channels[0] + 0.7152 * channels[1] + 0.0722 * channels[2] < 0.4;
12
+ };
3
13
 
4
14
  export function initSettings(app) {
5
15
  const $ = app.$;
@@ -15,24 +25,68 @@ export function initSettings(app) {
15
25
  $("#settingsPanelIntegrations")?.remove();
16
26
  }
17
27
  const tabs = [...dialog.querySelectorAll('[role="tab"]')];
28
+ const customColorInput = $("#inCustomThemeColor");
18
29
  const scheme = matchMedia("(prefers-color-scheme: dark)");
19
30
  let opener = null;
31
+ let customFrame = 0;
32
+ let customPersistTimer = 0;
33
+ let pendingCustomColor = "";
34
+ const CUSTOM_COLOR_PERSIST_DELAY = 300;
35
+
36
+ const customColor = () => validColor(app.LS.customTheme);
37
+ const paintCustomColor = (color) => {
38
+ document.documentElement.style.setProperty("--custom-bg", color);
39
+ document.documentElement.dataset.customDark = String(isDarkColor(color));
40
+ if (customColorInput) customColorInput.value = color;
41
+ };
42
+ const syncCustomColor = () => {
43
+ const color = customColor();
44
+ paintCustomColor(color);
45
+ return color;
46
+ };
47
+ // Live drags coalesce to one paint per frame; storage and theme metadata wait.
48
+ const clearCustomSchedules = () => {
49
+ if (customFrame) cancelAnimationFrame(customFrame);
50
+ customFrame = 0;
51
+ clearTimeout(customPersistTimer);
52
+ customPersistTimer = 0;
53
+ pendingCustomColor = "";
54
+ };
55
+ const scheduleCustomPaint = (color) => {
56
+ pendingCustomColor = color;
57
+ if (customFrame) return;
58
+ customFrame = requestAnimationFrame(() => {
59
+ customFrame = 0;
60
+ paintCustomColor(pendingCustomColor);
61
+ });
62
+ };
63
+ const commitCustomColor = (color) => {
64
+ clearCustomSchedules();
65
+ app.LS.customTheme = color;
66
+ if (document.documentElement.dataset.theme === "custom") {
67
+ paintCustomColor(color);
68
+ syncThemeColor();
69
+ } else applyTheme("custom", true);
70
+ };
20
71
 
21
72
  const syncThemeColor = () => {
22
73
  const meta = document.querySelector('meta[name="theme-color"]');
23
74
  const token = document.documentElement.dataset.windowFrame === "borderless" ? "--surface" : "--bg";
24
- const background = getComputedStyle(document.documentElement).getPropertyValue(token).trim();
75
+ const background = document.documentElement.dataset.theme === "custom" ? customColor() : getComputedStyle(document.documentElement).getPropertyValue(token).trim();
25
76
  if (meta && background) meta.content = background;
26
77
  };
27
78
  const syncThemeInputs = () => {
28
79
  const stored = THEMES.includes(app.LS.theme) ? app.LS.theme : "system";
29
80
  for (const input of dialog.querySelectorAll('input[name="theme"]')) input.checked = input.value === stored;
81
+ if (customColorInput) customColorInput.value = customColor();
30
82
  };
31
83
  const syncPanelInputs = () => {
32
84
  for (const select of panelInputs) select.value = app.panelMode(select.dataset.panelMode);
33
85
  };
34
86
  const applyTheme = (value, persist) => {
87
+ clearCustomSchedules();
35
88
  const theme = THEMES.includes(value) ? value : "system";
89
+ syncCustomColor();
36
90
  document.documentElement.dataset.theme = theme;
37
91
  if (persist) app.LS.theme = theme;
38
92
  syncThemeInputs();
@@ -110,13 +164,25 @@ export function initSettings(app) {
110
164
  dialog.close();
111
165
  };
112
166
  $("#btnCloseSettings")?.addEventListener("click", close);
113
- dialog.addEventListener("click", (event) => { if (event.target === dialog) close(); });
114
167
  dialog.addEventListener("cancel", () => opener?.setAttribute("aria-expanded", "false"));
115
168
  pageInput?.addEventListener("input", () => {
116
169
  app.LS.pageStep = pageInput.value;
117
170
  pageInput.value = String(app.LS.pageStep);
118
171
  if (pageValue) pageValue.textContent = `${app.LS.pageStep}%`;
119
172
  });
173
+ customColorInput?.addEventListener("input", () => {
174
+ const color = validColor(customColorInput.value);
175
+ scheduleCustomPaint(color);
176
+ clearTimeout(customPersistTimer);
177
+ customPersistTimer = setTimeout(() => {
178
+ customPersistTimer = 0;
179
+ commitCustomColor(validColor(customColorInput.value));
180
+ }, CUSTOM_COLOR_PERSIST_DELAY);
181
+ });
182
+ // Release commits the final color and flushes both the paint and storage at once.
183
+ customColorInput?.addEventListener("change", () => {
184
+ commitCustomColor(validColor(customColorInput.value));
185
+ });
120
186
  dialog.addEventListener("change", (event) => {
121
187
  if (event.target instanceof HTMLInputElement && event.target.name === "theme") app.setTheme(event.target.value);
122
188
  if (event.target === frameSelect) app.setWindowFrame(frameSelect.value);
@@ -25,9 +25,6 @@ export function initShortcuts(app) {
25
25
  app.$("#btnShortcuts")?.addEventListener("mousedown", (event) => event.preventDefault());
26
26
  app.$("#btnShortcuts")?.addEventListener("click", openSheet);
27
27
  app.$("#btnCloseShortcuts")?.addEventListener("click", () => dialog.close());
28
- dialog.addEventListener("click", (event) => {
29
- if (event.target === dialog) dialog.close();
30
- });
31
28
  dialog.addEventListener("close", () => requestAnimationFrame(() => app.focusComposer?.()));
32
29
  let scrollFrame = 0;
33
30
  let scrollGeneration = 0;
@@ -1,13 +1,15 @@
1
1
  // Resizes the right-hand pane (Markdown preview or task board) on wide windows.
2
- // --side-pane-width holds the only width; the rail keeps its 252px column and the
3
- // chat column never shrinks below MIN_CHAT.
2
+ // --side-pane-width holds the only width; responsive.css owns its default
3
+ // (up to 1080px at 1700x900+), while this splitter clamps a user-chosen width.
4
+ // The rail keeps its 252px column and the chat column never shrinks below MIN_CHAT.
4
5
  const STORAGE_KEY = "chat.sidePaneWidth";
5
6
  const MIN_WIDTH = 360;
6
7
  const MIN_CHAT = 420;
7
8
  const WIDE_TASKS_MIN_CHAT = 700;
8
9
  const RAIL_WIDTH = 252;
9
10
  const GUTTER = 8;
10
- const MAX_WIDTH = 960;
11
+ const MAX_WIDTH = 1080;
12
+ const ANIMATION_MS = 220;
11
13
 
12
14
  export function initSidePaneSplitter(app) {
13
15
  const view = app.$("#chatView");
@@ -20,9 +22,23 @@ export function initSidePaneSplitter(app) {
20
22
  let frame = 0;
21
23
  let pending = 0;
22
24
  let drag = null;
25
+ let paneWasOpen = view.classList.contains("has-doc") || view.classList.contains("has-pane");
26
+ let animationTimer = 0;
23
27
 
24
28
  const activePane = () => view.classList.contains("has-doc") ? preview
25
29
  : view.classList.contains("has-pane") ? view.querySelector(":scope > dialog.is-pane[open]") : null;
30
+ const paneOpen = () => view.classList.contains("has-doc") || view.classList.contains("has-pane");
31
+
32
+ // Only an open or close class change animates the column; dragging and window
33
+ // resizes apply their width immediately.
34
+ const animatePane = () => {
35
+ const open = paneOpen();
36
+ if (open === paneWasOpen) return;
37
+ paneWasOpen = open;
38
+ view.classList.add("pane-animating");
39
+ clearTimeout(animationTimer);
40
+ animationTimer = setTimeout(() => view.classList.remove("pane-animating"), ANIMATION_MS);
41
+ };
26
42
 
27
43
  // A wide task board must leave the conversation a full working column; the
28
44
  // Markdown preview keeps the normal minimum.
@@ -41,7 +57,9 @@ export function initSidePaneSplitter(app) {
41
57
  handle.setAttribute("aria-valuemax", String(Math.round(maxWidth())));
42
58
  const pane = activePane();
43
59
  if (pane?.open) {
44
- handle.setAttribute("aria-valuenow", String(Math.round(pane.getBoundingClientRect().width)));
60
+ // During the open transition the layout is still moving; report the
61
+ // width we asked for, not a frame of the animation.
62
+ handle.setAttribute("aria-valuenow", String(Math.round(applied || pane.getBoundingClientRect().width)));
45
63
  }
46
64
  };
47
65
 
@@ -55,7 +73,7 @@ export function initSidePaneSplitter(app) {
55
73
  // attribute changes when the workspace first appears.
56
74
  const reflow = () => {
57
75
  if (!view.clientWidth) return;
58
- if (stored == null) syncAria();
76
+ if (stored == null) { applied = 0; syncAria(); }
59
77
  else apply(clamp(stored));
60
78
  };
61
79
 
@@ -108,7 +126,7 @@ export function initSidePaneSplitter(app) {
108
126
 
109
127
  handle.addEventListener("keydown", (event) => {
110
128
  if (!activePane()?.open) return;
111
- const current = activePane().getBoundingClientRect().width;
129
+ const current = applied || activePane().getBoundingClientRect().width;
112
130
  const step = event.shiftKey ? 64 : 16;
113
131
  let next;
114
132
  if (event.key === "ArrowRight") next = current - step;
@@ -122,13 +140,20 @@ export function initSidePaneSplitter(app) {
122
140
 
123
141
  handle.addEventListener("dblclick", () => {
124
142
  stored = null;
143
+ applied = 0;
125
144
  try { localStorage.removeItem(STORAGE_KEY); } catch { /* Ignore unavailable storage. */ }
126
145
  view.style.removeProperty("--side-pane-width");
127
146
  syncAria();
128
147
  });
129
148
 
130
- window.addEventListener("resize", reflow);
131
- new MutationObserver(reflow).observe(view, { attributes: true, attributeFilter: ["class", "hidden"] });
149
+ window.addEventListener("resize", () => {
150
+ view.classList.remove("pane-animating");
151
+ reflow();
152
+ });
153
+ new MutationObserver(() => {
154
+ animatePane();
155
+ reflow();
156
+ }).observe(view, { attributes: true, attributeFilter: ["class", "hidden"] });
132
157
  reflow();
133
158
  }
134
159
 
@@ -160,6 +160,7 @@ export function createAuth(storage, fetcher, translate = (key) => key, sessionSt
160
160
  get token() { return read("chat.token") || ""; }, set token(value) { write("chat.token", value || null); },
161
161
  get locale() { return read("chat.locale") || "en"; }, set locale(value) { write("chat.locale", value || null); },
162
162
  get theme() { return read("chat.theme") || "system"; }, set theme(value) { write("chat.theme", value || null); },
163
+ get customTheme() { return read("chat.customTheme") || "#22695c"; }, set customTheme(value) { write("chat.customTheme", value || null); },
163
164
  get windowFrame() {
164
165
  return read("chat.windowFrame") === "borderless" ? "borderless" : "framed";
165
166
  },
@@ -299,9 +300,16 @@ export const messages = {
299
300
  answerFailed: "Reply failed. Your draft is still here.", answerTooLong: "Reply must be 5,000 characters or fewer.", questionAlreadyAnswered: "This question was answered elsewhere.",
300
301
  adminBindingGuide: "Choose a room and an Agent in it. Send the invitation privately to finish setup.", adminRoomLabel: "Administrator room", adminDesignateAgent: "Invite Agent",
301
302
  settings: "Settings", adminAccess: "Administration", adminToken: "Administration token", openAdministration: "Open administration", administration: "Administration", designations: "Designations", adminRoom: "Administrator room", targetRoom: "Agent membership room", adminScopeNote: "Choose an Agent in the administrator room. Administrators can manage all rooms.", targetAgent: "Registered agent", designate: "Designate administrator", revokeDesignation: "Revoke designation", globalStatus: "Global status", adminTasks: "Tasks", taskText: "Task", dispatchTask: "Dispatch task", timers: "Timers", planName: "Timer name", createTimer: "Create timer", tokenRequired: "The server requires an access token (401).",
302
- themeLabel: "Theme", themeSystem: "System", themeLight: "Light", themeDark: "Dark", themeForest: "Forest", themeSand: "Sand",
303
- windowFrameLabel: "Window frame", windowFrameHint: "Framed keeps the inset card; Borderless fills the window.",
304
- windowFrameFramed: "Framed", windowFrameBorderless: "Borderless",
303
+ themeLabel: "Theme", themeSystem: "System", themeLight: "Light", themeDark: "Dark", themeForest: "Forest", themeSand: "Sand", themeCustom: "Custom", themeCustomColor: "Custom theme color",
304
+ windowFrameLabel: "Display mode", windowFrameHint: "Fill window uses the entire window; Window mode keeps the inset card border.",
305
+ windowFrameFramed: "Window mode", windowFrameBorderless: "Fill window",
306
+ chatBackgroundLabel: "Chat background", chatBackgroundHint: "Fills the browser window behind the app in this browser only. A lower opacity keeps text readable.",
307
+ chatBackgroundMode: "Mode", chatBackgroundDefault: "Default", chatBackgroundColor: "Color", chatBackgroundImage: "Image",
308
+ chatBackgroundOpacity: "Opacity", chatBackgroundScope: "Scope", chatBackgroundScopeRoom: "This room", chatBackgroundScopeAll: "All rooms",
309
+ chatBackgroundReset: "Reset", chatBackgroundTooLarge: "Choose an image of 2 MiB or less.",
310
+ chatBackgroundInvalidType: "Choose an image file.",
311
+ chatBackgroundApplying: "Reading {name}…", chatBackgroundApplied: "{name} applied.",
312
+ chatBackgroundImageFailed: "Could not read this image.", chatBackgroundSaveFailed: "Could not save the background in this browser.",
305
313
  settingsLocalHint: "Language, theme, transition, and scrolling preferences are saved in this browser.",
306
314
  settingsSections: "Settings sections", settingsGeneral: "General", settingsAppearance: "Appearance", settingsConnection: "Connection",
307
315
  settingsLanguageHint: "Applies right away and is saved in this browser.", settingsThemeHint: "Saved in this browser. System follows your device.", settingsTokenHint: "Stored only in this browser. Needed only when the server asks for it.",
@@ -309,7 +317,7 @@ export const messages = {
309
317
  settingsIntegrations: "Integrations",
310
318
  integrationsHint: "Connect rooms with external platforms through uploaded plugins. Secret values stay on the server.",
311
319
  integrationsExternalConfig: "This integration uses an external configuration file. Edit that file, or disable it before saving managed settings.",
312
- integrationsEnable: "Enable integrations", integrationsEnableHint: "Starts or stops the integration runtime immediately.",
320
+ integrationsEnable: "Enable integrations", integrationsEnableHint: "Changes apply when you save.",
313
321
  integrationsAccounts: "Accounts", integrationsAddAccount: "Add account", integrationsEmptyAccounts: "No accounts yet.",
314
322
  integrationsPlugins: "Plugins", integrationsUploadPlugin: "Upload plugin", integrationsEmptyPlugins: "No plugins uploaded yet.",
315
323
  integrationsRules: "Outbound rules", integrationsRulesHint: "Outbound rules forward room events to connected accounts. Use JSON or YAML; each target must use an existing account.",
@@ -321,8 +329,10 @@ export const messages = {
321
329
  integrationsLeaveBlank: "Leave blank to keep this stored value", integrationsEnvHint: "Entering a value replaces only that variable. Blank rows keep their stored value.",
322
330
  integrationsAddEnv: "Add variable", integrationsClearEnv: "Clear all variables", integrationsKeepEnv: "Keep all variables",
323
331
  integrationsClearEnvActive: "All stored variables will be cleared when you save.", integrationsEnvInvalid: "Use unique variable names made of letters, digits, and underscores.",
324
- integrationsAccountTitle: "Integration account", integrationsAccountId: "Account ID", integrationsPlatform: "Platform",
325
- integrationsAccountInvalid: "Add an account ID and choose a plugin.", integrationsDuplicateAccount: "An account with this ID already exists.",
332
+ integrationsAccountTitle: "Integration account", integrationsAccountId: "Account ID", integrationsAccountIdHint: "Leave blank to generate", integrationsPlatform: "Platform",
333
+ integrationsAccountDetails: "Account details", integrationsAdvanced: "Advanced settings", integrationsKeepStored: "Keep stored value", integrationsNotSet: "Not set",
334
+ integrationsAccountRequired: "Fill required account fields: {fields}.",
335
+ integrationsAccountInvalid: "Choose a plugin; the account ID can be generated automatically.", integrationsRemoveAccountConfirm: ({ id }) => `Remove account “${id}”? It is deleted after you save the integrations.`, integrationsDuplicateAccount: "An account with this ID already exists.",
326
336
  integrationsAccountSaved: "Account saved. Save integrations to apply it.", integrationsAccountRemoved: "Account removed. Save integrations to apply it.",
327
337
  integrationsLastError: "Last error", integrationsEdit: "Edit", integrationsRemove: "Remove",
328
338
  integrationsInvalidJson: "Rules JSON is invalid near line {line}.", integrationsInvalidRules: "Rules must be a JSON array.",
@@ -331,13 +341,15 @@ export const messages = {
331
341
  integrationsNeedAccount: "Add at least one account before saving.", integrationsPluginFirst: "Upload a plugin before adding an account.",
332
342
  integrationsStateStarted: "Running", integrationsStateStarting: "Starting", integrationsStateStopped: "Stopped",
333
343
  integrationsStateError: "Error", integrationsStateUnknown: "Unknown",
334
- integrationsPluginFile: "Choose a JS file", integrationsPluginName: "Plugin name", integrationsPluginSource: "JavaScript source",
344
+ integrationsPluginFile: "Choose an adapter file", integrationsPluginName: "Plugin name", integrationsPluginSource: "JavaScript source",
345
+ integrationsPluginHint: "A valid adapter declares its platform and account fields from the initialize handshake. Upload does not start the account or require credentials.",
346
+ integrationsDownloadPlugin: "Download {name}",
335
347
  integrationsPluginPaste: "Paste plugin JavaScript (max 256 KiB)", integrationsUpload: "Upload plugin",
336
348
  integrationsUploaded: "Plugin uploaded. Choose it for an account.", integrationsSourceTooLarge: "The plugin source must be at most 256 KiB.",
337
- integrationsNameRequired: "Use a .js, .mjs, or .cjs file name.", integrationsPlatformRequired: "Use a platform identifier of 1–128 letters, digits, dots, dashes, or underscores.",
349
+ integrationsNameRequired: "Use a .js, .mjs, .cjs, or .ts file name.", integrationsPlatformRequired: "Use a platform identifier of 1–128 letters, digits, dots, dashes, or underscores.",
338
350
  integrationsSourceRequired: "Paste or choose plugin JavaScript.",
339
351
  integrationsEnabled: "Integrations are enabled.", integrationsDisabled: "Integrations are disabled.", integrationsEnablePending: "Save integrations to start the runtime.",
340
- integrationsSavedEnabled: "Saved. Integrations are enabled.", integrationsSavedDisabled: "Saved. Integrations are disabled.",
352
+ integrationsSavedEnabled: "Saved. Integrations are enabled.", integrationsDisableConfirm: "Disable integrations? Saving stops the runtime; accounts and rules stay stored.", integrationsDisabledHint: "Enable integrations and save to edit accounts, plugins, and rules.", integrationsSavedDisabled: "Saved. Integrations are disabled.",
341
353
  contentTransition: "Room content transition", contentTransitionHint: "Slide messages in when switching rooms with Alt+Arrow. Off by default.",
342
354
  pageStep: "Page scroll distance", pageStepHint: "How far PageUp and PageDown move per press, as a percentage of the conversation height. Default 90%.",
343
355
  adminLoading: "Loading administration…", refreshAdmin: "Refresh", adminRoomBadge: "admin", chooseAdminRoom: "Choose a normal room", chooseTargetRoom: "Choose an agent room", chooseAgent: "Choose a registered agent", taskTargetRoom: "Target room", taskTargetAgent: "Target agent", createAdminRoomFirst: "Create a normal room first, then select it as the admin room.", noAgents: "No registered agents", selectAdminAgent: "Choose an admin room and registered agent.", adminDesignated: "Administrator designation is active immediately and stays until you revoke it.", revokeConfirm: "Revoke this admin designation? The normal room will remain.", updateTask: "Update task", task_pending: "Pending", task_working: "Working", task_blocked: "Blocked", task_completed: "Completed", task_cancelled: "Cancelled", nextRun: ({ time, minutes }) => `Every ${minutes} min · next ${time}`, paused: "Paused", pauseTimer: "Pause", resumeTimer: "Resume", deleteTimer: "Delete", deleteTimerConfirm: ({ name }) => `Delete timer “${name}”?`,
@@ -494,16 +506,23 @@ export const messages = {
494
506
  adminAccess: "管理", adminToken: "管理令牌", openAdministration: "打开管理面板", administration: "管理面板", designations: "管理绑定", adminRoom: "管理员房间", targetRoom: "Agent 所属房间", adminScopeNote: "请选择管理员房间内的 Agent。管理员可以管理所有房间。", adminRoomBadge: "管理", targetAgent: "已注册 Agent", designate: "指定管理员", revokeDesignation: "撤销绑定", globalStatus: "全局状态", adminTasks: "任务", taskText: "任务内容", dispatchTask: "派发任务", timers: "定时任务", planName: "定时任务名称", createTimer: "创建定时任务",
495
507
  adminLoading: "正在加载管理面板…", refreshAdmin: "刷新", adminRoomBadge: "管理", chooseAdminRoom: "选择普通房间", chooseTargetRoom: "选择 Agent 房间", chooseAgent: "选择已注册 Agent", taskTargetRoom: "任务目标房间", taskTargetAgent: "任务目标 Agent", createAdminRoomFirst: "请先按普通流程创建房间,再选作管理房间。", noAgents: "没有已注册的 Agent", selectAdminAgent: "请选择管理房间和已注册的 Agent。", adminDesignated: "管理员已立即生效,长期有效,直到撤销。", revokeConfirm: "撤销此管理绑定?普通房间会保留。", updateTask: "更新任务", task_pending: "待处理", task_working: "进行中", task_blocked: "受阻", task_completed: "已完成", task_cancelled: "已取消", nextRun: ({ time, minutes }) => `每 ${minutes} 分钟 · 下次 ${time}`, paused: "已暂停", pauseTimer: "暂停", resumeTimer: "恢复", deleteTimer: "删除", deleteTimerConfirm: ({ name }) => `删除定时任务“${name}”?`,
496
508
  tokenRequired: "服务器要求访问令牌(401)。",
497
- themeLabel: "主题", themeSystem: "跟随系统", themeLight: "浅色", themeDark: "深色", themeForest: "森林", themeSand: "沙丘",
498
- windowFrameLabel: "窗口边框", windowFrameHint: "有边框保留内嵌卡片,无边框铺满窗口。",
499
- windowFrameFramed: "有边框", windowFrameBorderless: "无边框",
509
+ themeLabel: "主题", themeSystem: "跟随系统", themeLight: "浅色", themeDark: "深色", themeForest: "森林", themeSand: "沙丘", themeCustom: "自定义主题", themeCustomColor: "自定义主题颜色",
510
+ windowFrameLabel: "显示模式", windowFrameHint: "内容铺满占满整个窗口;窗口模式保留内嵌卡片边框。",
511
+ windowFrameFramed: "窗口模式", windowFrameBorderless: "内容铺满",
512
+ chatBackgroundLabel: "聊天背景", chatBackgroundHint: "仅显示在当前浏览器,铺满应用后面的整个窗口。透明度低一些更易阅读。",
513
+ chatBackgroundMode: "模式", chatBackgroundDefault: "默认", chatBackgroundColor: "颜色", chatBackgroundImage: "图片",
514
+ chatBackgroundOpacity: "透明度", chatBackgroundScope: "范围", chatBackgroundScopeRoom: "当前房间", chatBackgroundScopeAll: "所有房间",
515
+ chatBackgroundReset: "重置", chatBackgroundTooLarge: "请选择不超过 2 MiB 的图片。",
516
+ chatBackgroundInvalidType: "请选择图片文件。",
517
+ chatBackgroundApplying: "正在读取 {name}…", chatBackgroundApplied: "已应用 {name}。",
518
+ chatBackgroundImageFailed: "无法读取这张图片。", chatBackgroundSaveFailed: "无法在当前浏览器保存背景。",
500
519
  settingsLocalHint: "语言、主题、过渡和滚动选项保存在当前浏览器中。", settingsSections: "设置分区", settingsGeneral: "通用", settingsAppearance: "外观", settingsConnection: "连接",
501
520
  settingsLanguageHint: "立即生效,并保存在当前浏览器中。", settingsThemeHint: "保存在当前浏览器中。跟随系统会使用设备的外观设置。", settingsTokenHint: "仅保存在当前浏览器中,仅在服务器要求时填写。",
502
521
  settingsPanelMode: "工具窗口", settingsPanelModeHint: "选择每个房间工具在宽屏上的打开方式。窄屏或矮窗口始终使用弹窗。", panelModeDialog: "弹窗", panelModePane: "侧边栏",
503
522
  settingsIntegrations: "平台集成",
504
523
  integrationsHint: "通过上传插件把房间连接到外部平台。密钥值只保存在服务器上。",
505
524
  integrationsExternalConfig: "此集成使用外部配置文件。请编辑该文件,或在保存托管设置前先停用它。",
506
- integrationsEnable: "启用集成", integrationsEnableHint: "立即启动或停止集成运行时。",
525
+ integrationsEnable: "启用集成", integrationsEnableHint: "保存后生效。",
507
526
  integrationsAccounts: "账号", integrationsAddAccount: "添加账号", integrationsEmptyAccounts: "还没有账号。",
508
527
  integrationsPlugins: "插件", integrationsUploadPlugin: "上传插件", integrationsEmptyPlugins: "还没有上传插件。",
509
528
  integrationsRules: "出站规则", integrationsRulesHint: "出站规则把房间事件转发到已连接的账号。可使用 JSON 或 YAML;每个目标必须使用已存在的账号。",
@@ -515,8 +534,10 @@ export const messages = {
515
534
  integrationsLeaveBlank: "留空以保留该变量的已存储值", integrationsEnvHint: "填写某个值只会替换该变量;留空的行保持原值。",
516
535
  integrationsAddEnv: "添加变量", integrationsClearEnv: "清除所有变量", integrationsKeepEnv: "保留所有变量",
517
536
  integrationsClearEnvActive: "保存后将清除所有已存储的变量。", integrationsEnvInvalid: "变量名只能包含字母、数字和下划线,且不能重复。",
518
- integrationsAccountTitle: "集成账号", integrationsAccountId: "账号 ID", integrationsPlatform: "平台",
519
- integrationsAccountInvalid: "请填写账号 ID 并选择插件。", integrationsDuplicateAccount: "已存在相同 ID 的账号。",
537
+ integrationsAccountTitle: "集成账号", integrationsAccountId: "账号 ID", integrationsAccountIdHint: "留空自动生成", integrationsPlatform: "平台",
538
+ integrationsAccountDetails: "账号信息", integrationsAdvanced: "高级设置", integrationsKeepStored: "保留已存储值", integrationsNotSet: "未设置",
539
+ integrationsAccountRequired: "请填写必填的账号字段:{fields}。",
540
+ integrationsAccountInvalid: "请选择插件;账号 ID 可以留空自动生成。", integrationsRemoveAccountConfirm: ({ id }) => `确定移除账号“${id}”?保存集成配置后才会真正删除。`, integrationsDuplicateAccount: "已存在相同 ID 的账号。",
520
541
  integrationsAccountSaved: "账号已保存。保存集成后生效。", integrationsAccountRemoved: "账号已移除。保存集成后生效。",
521
542
  integrationsLastError: "最近错误", integrationsEdit: "编辑", integrationsRemove: "移除",
522
543
  integrationsInvalidJson: "规则 JSON 在第 {line} 行附近无效。", integrationsInvalidRules: "规则必须是 JSON 数组。",
@@ -525,13 +546,15 @@ export const messages = {
525
546
  integrationsNeedAccount: "保存前请至少添加一个账号。", integrationsPluginFirst: "请先上传插件,再添加账号。",
526
547
  integrationsStateStarted: "运行中", integrationsStateStarting: "启动中", integrationsStateStopped: "已停止",
527
548
  integrationsStateError: "错误", integrationsStateUnknown: "未知",
528
- integrationsPluginFile: "选择 JS 文件", integrationsPluginName: "插件文件名", integrationsPluginSource: "JavaScript 源码",
549
+ integrationsPluginFile: "选择适配器文件", integrationsPluginName: "插件文件名", integrationsPluginSource: "JavaScript 源码",
550
+ integrationsPluginHint: "合法插件会在 initialize 握手中声明平台和账号字段;上传不会启动账号,也不需要凭据。",
551
+ integrationsDownloadPlugin: "下载 {name}",
529
552
  integrationsPluginPaste: "粘贴插件 JavaScript(最大 256 KiB)", integrationsUpload: "上传插件",
530
553
  integrationsUploaded: "插件已上传。请为账号选择它。", integrationsSourceTooLarge: "插件源码不能超过 256 KiB。",
531
- integrationsNameRequired: "请使用 .js、.mjs 或 .cjs 文件名。", integrationsPlatformRequired: "平台标识需为 1–128 个字母、数字、点、短横线或下划线。",
554
+ integrationsNameRequired: "请使用 .js、.mjs、.cjs 或 .ts 文件名。", integrationsPlatformRequired: "平台标识需为 1–128 个字母、数字、点、短横线或下划线。",
532
555
  integrationsSourceRequired: "请粘贴或选择插件 JavaScript。",
533
556
  integrationsEnabled: "集成已启用。", integrationsDisabled: "集成已停用。", integrationsEnablePending: "保存集成后即可启动运行时。",
534
- integrationsSavedEnabled: "已保存,集成已启用。", integrationsSavedDisabled: "已保存,集成已停用。",
557
+ integrationsSavedEnabled: "已保存,集成已启用。", integrationsDisableConfirm: "停用集成?保存后运行时会停止;账号和规则仍会保留。", integrationsDisabledHint: "启用集成并保存后,才能编辑账号、插件和规则。", integrationsSavedDisabled: "已保存,集成已停用。",
535
558
  contentTransition: "内容区域过渡", contentTransitionHint: "使用 Alt+方向键切换房间时,让消息内容按方向滑动。默认关闭。", pageStep: "翻页距离", pageStepHint: "每次按 PageUp 或 PageDown 滚动会话高度的百分比。默认 90%。", leave: "离开", reconnecting: "连接中断,正在重试…",
536
559
  messageList: "消息列表", noMessages: "还没有消息,说点什么吧。", latestMessages: "回到最新消息",
537
560
  mentionMembers: "选择要提及的成员", messagePlaceholder: "输入消息,Enter 发送",
@@ -625,6 +648,13 @@ export const messages = {
625
648
  ...extraLocales,
626
649
  };
627
650
 
651
+ // Every locale falls back to English for keys it has not translated yet.
652
+ for (const dictionary of Object.values(messages)) {
653
+ for (const key of Object.keys(messages.en)) {
654
+ if (dictionary[key] === undefined) dictionary[key] = messages.en[key];
655
+ }
656
+ }
657
+
628
658
  app.t = (key, values = {}) => {
629
659
  const entry = messages[app.locale][key] ?? messages.en[key] ?? key;
630
660
  const text = typeof entry === "function" ? entry(values) : entry;
@@ -1,6 +1,7 @@
1
1
  // Room notices are inline events: a small icon, a tinted chip, and the time.
2
2
  import { iconNode } from "./icons.js";
3
- import { formatSystemMessage, systemMessageKind } from "./system-messages.js";
3
+ import { formatRelayMessage, formatSystemMessage, systemMessageKind } from "./system-messages.js";
4
+ import { renderMarkdown, renderResourceText } from "./markdown.js";
4
5
 
5
6
  const icons = {
6
7
  join: "add",
@@ -12,6 +13,26 @@ const icons = {
12
13
  notice: "megaphone",
13
14
  };
14
15
 
16
+ // Notices are Markdown and switch from a pill to a card once they pass three
17
+ // rendered lines; relays always keep the message-card shape because they carry
18
+ // attachments.
19
+ function markNoticeShape(row) {
20
+ if (row.dataset.kind === "relay") return;
21
+ const text = row.querySelector(".sys-text");
22
+ if (!text || !text.isConnected) return;
23
+ const lineHeight = Number.parseFloat(getComputedStyle(text).lineHeight) || 18;
24
+ row.dataset.long = text.getBoundingClientRect().height > lineHeight * 3 + 1 ? "true" : "false";
25
+ }
26
+
27
+ let resizeBound = false;
28
+ function bindNoticeResize() {
29
+ if (resizeBound) return;
30
+ resizeBound = true;
31
+ window.addEventListener("resize", () => {
32
+ for (const row of document.querySelectorAll('.sys[data-kind]:not([data-kind="relay"])')) markNoticeShape(row);
33
+ }, { passive: true });
34
+ }
35
+
15
36
  export function renderSystemRow(row, message, app) {
16
37
  row.className = "sys";
17
38
  row.dataset.kind = systemMessageKind(message);
@@ -22,11 +43,16 @@ export function renderSystemRow(row, message, app) {
22
43
  mark.className = "sys-icon";
23
44
  mark.append(iconNode(icons[row.dataset.kind] || icons.notice, "sys-icon-glyph"));
24
45
  text.className = "sys-text";
25
- text.textContent = formatSystemMessage(message, app);
46
+ if (row.dataset.kind === "relay") renderResourceText(text, formatRelayMessage(message, app), app);
47
+ else renderMarkdown(text, formatSystemMessage(message, app), app);
26
48
  time.className = "sys-time";
27
49
  time.dateTime = new Date(message.createdAt).toISOString();
28
- time.textContent = app.messageTime(message.createdAt);
50
+ // Notices and relays both put a full, muted date first; a bare clock is
51
+ // ambiguous once a row has scrolled or came from another timezone.
52
+ time.textContent = app.fmtTime(message.createdAt);
29
53
  event.append(mark, text, time);
30
54
  row.append(event);
55
+ bindNoticeResize();
56
+ requestAnimationFrame(() => markNoticeShape(row));
31
57
  return row;
32
58
  }
@@ -24,6 +24,13 @@ function formatLine(line, app) {
24
24
  return line;
25
25
  }
26
26
 
27
+ export function formatRelayMessage(message, app) {
28
+ // Relay rows keep resource markers: the renderer turns them into attachment cards.
29
+ return String(message?.text ?? "")
30
+ .replace(/<at>@all<\/at>/g, `@${app.t("allMembers")}`)
31
+ .replace(/<at>([\s\S]*?)<\/at>/g, "$1");
32
+ }
33
+
27
34
  export function formatSystemMessage(message, app) {
28
35
  // `<at>@name</at>` is an editor token; system rows and previews show the plain mention.
29
36
  let text = String(message?.text ?? "")
@@ -44,6 +51,8 @@ export function formatSystemMessage(message, app) {
44
51
  export function systemMessageKind(message) {
45
52
  if (String(message?.id ?? "").startsWith("reminder:")) return "reminder";
46
53
  const line = String(message?.text ?? "").split("; ")[0];
54
+ // Inbound relay lines carry provider ids and read like messages, not notices.
55
+ if (/^\[[A-Za-z][\w .-]*\] message_id=\S+/.test(line)) return "relay";
47
56
  for (const [pattern, , , kind] of patterns) if (pattern.test(line)) return kind;
48
57
  return "notice";
49
58
  }
@@ -462,7 +462,7 @@ export function initTasks(app) {
462
462
  });
463
463
 
464
464
  trigger.addEventListener("click", () => { app.closePanels(); open(); });
465
- app.registerPanelSurface?.("tasks", { close: () => close(false) });
465
+ app.registerPanelSurface?.("tasks", { element: dialog, close: (restore = false) => close(restore) });
466
466
  app.watchPanel?.("tasks", syncMode);
467
467
  $("#btnCloseTasks")?.addEventListener("click", () => close());
468
468
  refresh.addEventListener("click", () => { if (!editingId) void load(); });
@@ -542,16 +542,10 @@ export function initTasks(app) {
542
542
  });
543
543
 
544
544
  $("#btnCloseTaskEdit")?.addEventListener("click", () => closeEdit(true));
545
- editDialog.addEventListener("click", (event) => {
546
- if (event.target === editDialog) closeEdit(true);
547
- });
548
545
  editDialog.addEventListener("cancel", (event) => { event.preventDefault(); closeEdit(true); });
549
- dialog.addEventListener("click", (event) => {
550
- if (event.target === dialog && !dialog.classList.contains("is-pane")) close();
551
- });
552
546
  dialog.addEventListener("cancel", (event) => { event.preventDefault(); close(); });
553
547
  document.addEventListener("keydown", (event) => {
554
- if (event.key !== "Escape") return;
548
+ if (event.key !== "Escape" || event.altKey) return;
555
549
  if (!menu.hidden) {
556
550
  event.preventDefault();
557
551
  setMenu(false);
@@ -0,0 +1,37 @@
1
+ // Installed PWAs opt into the Window Controls Overlay through the manifest. Only a
2
+ // visible overlay gets the drag strip and titlebar inset; every other surface keeps
3
+ // its normal layout with no dead drag area.
4
+ const PROPS = ["top", "left", "width", "height"];
5
+
6
+ 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
+ }