@alexsun-top/opencode-chat-room 0.8.0 → 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.
- package/CHANGELOG.md +52 -0
- package/LICENSE +2 -2
- package/README.md +40 -8
- package/README.zh-CN.md +40 -8
- package/cli.ts +27 -1
- package/dist/cli.js +5406 -3088
- package/package.json +25 -5
- package/packages/chat-room-channeld/README.md +111 -33
- package/packages/chat-room-channeld/src/adapter.ts +179 -7
- package/packages/chat-room-channeld/src/config.ts +63 -1
- package/packages/chat-room-channeld/src/delivery.ts +6 -1
- package/packages/chat-room-channeld/src/host-helpers.ts +11 -0
- package/packages/chat-room-channeld/src/host.ts +142 -9
- package/packages/chat-room-channeld/src/inbound.ts +35 -0
- package/packages/chat-room-channeld/src/protocol.ts +52 -1
- package/packages/chat-room-channeld/src/rules.ts +7 -2
- package/packages/chat-room-channeld/src/state.ts +17 -0
- package/packages/chat-room-channeld/src/stats.ts +43 -1
- package/plugin.ts +1 -1
- package/server/admin-state.ts +13 -13
- package/server/app.ts +95 -0
- package/server/assets/NOTICE.txt +2 -1
- package/server/assets/base.css +21 -9
- package/server/assets/chat/admin.js +0 -2
- package/server/assets/chat/announcements.js +69 -8
- package/server/assets/chat/chat-background.js +177 -0
- package/server/assets/chat/confirm-dialog.js +0 -1
- package/server/assets/chat/create-room-dialog.js +0 -1
- package/server/assets/chat/diagram-viewer.js +7 -1
- package/server/assets/chat/doc-preview.js +251 -46
- package/server/assets/chat/events.js +16 -5
- package/server/assets/chat/files.js +53 -7
- package/server/assets/chat/image-zoom.js +8 -1
- package/server/assets/chat/index.js +6 -2
- package/server/assets/chat/integration-account-schema.js +99 -0
- package/server/assets/chat/integration-editor.js +163 -0
- package/server/assets/chat/integration-values.js +124 -0
- package/server/assets/chat/integrations.js +648 -0
- package/server/assets/chat/locales/de.js +40 -4
- package/server/assets/chat/locales/es.js +40 -4
- package/server/assets/chat/locales/fr.js +40 -4
- package/server/assets/chat/locales/it.js +40 -4
- package/server/assets/chat/locales/ja.js +40 -4
- package/server/assets/chat/locales/ko.js +40 -4
- package/server/assets/chat/markdown-footnotes.js +1 -1
- package/server/assets/chat/markdown.js +45 -8
- package/server/assets/chat/messages.js +6 -5
- package/server/assets/chat/office-preview.js +69 -0
- package/server/assets/chat/palette.js +6 -1
- package/server/assets/chat/panels.js +56 -0
- package/server/assets/chat/recall.js +58 -7
- package/server/assets/chat/receipts.js +17 -6
- package/server/assets/chat/reminders.js +68 -9
- package/server/assets/chat/replies.js +0 -6
- package/server/assets/chat/resource-format.js +11 -0
- package/server/assets/chat/rooms.js +1 -6
- package/server/assets/chat/settings.js +98 -4
- package/server/assets/chat/shortcuts.js +0 -3
- package/server/assets/chat/side-pane.js +34 -10
- package/server/assets/chat/state.js +125 -12
- package/server/assets/chat/system-events.js +58 -0
- package/server/assets/chat/system-messages.js +32 -14
- package/server/assets/chat/task-row.js +0 -6
- package/server/assets/chat/tasks.js +119 -37
- package/server/assets/chat/window-controls.js +37 -0
- package/server/assets/code-highlight.css +71 -32
- package/server/assets/conversation.css +174 -31
- package/server/assets/doc-preview.css +40 -3
- package/server/assets/files.css +8 -0
- package/server/assets/fluent-icons.svg +2 -0
- package/server/assets/monaco/LICENSE +21 -0
- package/server/assets/monaco/ThirdPartyNotices.txt +448 -0
- package/server/assets/monaco/codicon-jdswhhtn.ttf +0 -0
- package/server/assets/monaco/editor.worker.js +45 -0
- package/server/assets/monaco/integration-rules.css +1 -0
- package/server/assets/monaco/integration-rules.js +1605 -0
- package/server/assets/monaco/json.worker.js +77 -0
- package/server/assets/office/THIRD-PARTY-NOTICES.txt +11 -0
- package/server/assets/office/docx.bundle.js +33 -0
- package/server/assets/office/licenses/docx-preview-LICENSE.txt +201 -0
- package/server/assets/office/licenses/echarts-LICENSE.txt +222 -0
- package/server/assets/office/licenses/jszip-LICENSE.txt +651 -0
- package/server/assets/office/licenses/lodash-LICENSE.txt +47 -0
- package/server/assets/office/licenses/pptx-preview-LICENSE.txt +8 -0
- package/server/assets/office/licenses/tslib-LICENSE.txt +12 -0
- package/server/assets/office/licenses/uuid-LICENSE.txt +9 -0
- package/server/assets/office/licenses/xlsx-LICENSE.txt +201 -0
- package/server/assets/office/licenses/zrender-LICENSE.txt +29 -0
- package/server/assets/office/pptx.bundle.js +104 -0
- package/server/assets/office/xlsx.bundle.js +141 -0
- package/server/assets/recall.css +5 -4
- package/server/assets/responsive.css +80 -11
- package/server/assets/settings.css +185 -9
- package/server/assets/tasks.css +57 -7
- package/server/assets/window-controls.css +36 -0
- package/server/channel-attachments.ts +133 -0
- package/server/channel-integration.ts +572 -0
- package/server/channel-settings.ts +77 -0
- package/server/channels.ts +274 -21
- package/server/chat-server.ts +32 -580
- package/server/chat.html +234 -34
- package/server/http-server.ts +3 -182
- package/server/manifest.webmanifest +1 -0
- package/server/resource-routes.ts +16 -16
- package/server/routes/inbox.ts +100 -0
- package/server/routes/pages.ts +83 -0
- package/server/routes/questions.ts +39 -0
- package/server/routes/room-actions.ts +162 -0
- package/server/routes/rooms.ts +160 -0
- package/server/startup.ts +84 -0
- package/server/sw.js +5 -0
- package/server/task-routes.ts +1 -1
- package/src/center/center-client.ts +3 -11
- package/src/config/file-config.ts +7 -54
- package/src/platform/http-server.ts +182 -0
- package/src/protocol/addressing.ts +21 -0
- package/src/protocol/config.ts +58 -0
- package/src/protocol/room.ts +51 -0
- package/src/rooms/resources.ts +26 -16
- package/src/rooms/room-service.ts +2 -48
- package/src/rooms/storage.ts +329 -0
- package/src/rooms/tasks.ts +21 -5
- package/src/runtime/watch.ts +1 -1
- package/src/state/pg-database.ts +183 -0
- package/src/state/pg-migrate.ts +175 -0
- package/src/state/pg-sql.mjs +175 -0
- package/src/state/pg-worker.mjs +133 -0
- package/src/state/sqlite-announcements.ts +25 -0
- package/src/state/sqlite-database.ts +130 -0
- package/src/state/sqlite-legacy.ts +90 -0
- package/src/state/sqlite-members.ts +155 -0
- package/src/state/sqlite-messages.ts +288 -0
- package/src/state/sqlite-resources.ts +39 -0
- package/src/state/sqlite-rooms.ts +194 -0
- package/src/state/sqlite-schema.ts +80 -0
- package/src/state/sqlite-state-store.ts +34 -0
- package/src/state/sqlite-state.ts +15 -897
- package/src/state/sqlite-tasks.ts +65 -0
- package/src/state/sqlite-transaction.ts +13 -0
- package/src/state/sqlite.ts +21 -1
- package/src/state/store.ts +5 -1
- package/src/tui/app.mjs +32 -19
- package/src/tui/config.mjs +12 -4
- package/src/tui/i18n.mjs +38 -0
- package/src/tui/info-app.mjs +50 -51
- package/src/tui/info-content.mjs +79 -44
- package/src/tui/join-app.mjs +9 -9
- package/src/tui/locales/en.mjs +349 -0
- package/src/tui/locales/zh-CN.mjs +349 -0
- package/src/tui/main.mjs +85 -37
- package/src/tui/markdown.mjs +3 -2
- package/src/tui/mentions.mjs +3 -1
- package/src/tui/message-app.mjs +22 -21
- package/src/tui/message-view.mjs +2 -1
- package/src/tui/palette-app.mjs +9 -8
- package/src/tui/palette.mjs +30 -24
- package/src/tui/prefs.mjs +92 -0
- package/src/tui/reminder-app.mjs +18 -17
- package/src/tui/room-settings-app.mjs +30 -28
- package/src/tui/settings-app.mjs +153 -0
- package/src/tui/ui-content.mjs +65 -86
- package/src/tui/ui-help.mjs +73 -0
- package/src/tui/ui-overlay-view.mjs +23 -7
- package/src/tui/ui-suggest.mjs +6 -5
- package/src/tui/ui-theme.mjs +37 -33
- package/src/tui/ui-view.mjs +22 -7
- package/src/tui/ui.mjs +15 -3
- package/src/web/editor.worker.ts +1 -0
- package/src/web/integration-rules-editor.ts +573 -0
- package/src/web/integration-rules.ts +26 -0
- package/src/web/integration-schema.ts +229 -0
- package/src/web/json.worker.ts +1 -0
- package/src/web/office-viewer.ts +221 -0
- package/packages/chat-room-channeld/dist/feishu-adapter.js +0 -499
- package/packages/chat-room-channeld/src/feishu-adapter.ts +0 -473
- package/server/assets/chat/forward.js +0 -69
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { LS } from "./state.js";
|
|
2
2
|
|
|
3
3
|
export function initReminders(app) {
|
|
4
|
-
const $ = app.$,
|
|
5
|
-
const
|
|
4
|
+
const $ = app.$, surface = $("#remindersDialog"), trigger = $("#btnReminders"), list = $("#reminderList");
|
|
5
|
+
const dialog = $("#reminderDialog"), newButton = $("#btnNewReminder");
|
|
6
|
+
const heading = $("#reminderDialogHeading"), panelHeading = $("#reminderHeading"), submit = $("#btnSubmitReminder");
|
|
7
|
+
const chatView = $("#chatView");
|
|
6
8
|
app.setText($("#reminderTemplateHint"), "reminderTemplateHint", { time: "{time}", initiator: "{initiator}", room: "{room}" });
|
|
7
9
|
let reminders = [], generation = 0, roomGeneration = 0, activeRoomId, editing = null, createDraft = null, saving = false, saveToken = 0;
|
|
10
|
+
let opener = null, pendingReopen = false, restoreSurfaceFocus = true;
|
|
8
11
|
const drafts = new Map();
|
|
9
12
|
const roomId = () => app.state.room?.id;
|
|
10
13
|
const status = (text) => { $("#reminderStatus").textContent = text; };
|
|
@@ -23,6 +26,47 @@ export function initReminders(app) {
|
|
|
23
26
|
if (!dialog.open) dialog.showModal();
|
|
24
27
|
$("#reminderText").focus();
|
|
25
28
|
}
|
|
29
|
+
const clearPane = () => {
|
|
30
|
+
surface.classList.remove("is-pane");
|
|
31
|
+
if (chatView.dataset.sidePane !== "reminders") return;
|
|
32
|
+
delete chatView.dataset.sidePane;
|
|
33
|
+
chatView.classList.remove("has-pane");
|
|
34
|
+
};
|
|
35
|
+
const showSurface = () => {
|
|
36
|
+
if (app.panelPlacement("reminders") === "pane") {
|
|
37
|
+
app.closeOtherPanelSurfaces?.("reminders");
|
|
38
|
+
surface.classList.add("is-pane");
|
|
39
|
+
chatView.classList.add("has-pane");
|
|
40
|
+
chatView.dataset.sidePane = "reminders";
|
|
41
|
+
if (!surface.open) surface.show();
|
|
42
|
+
} else {
|
|
43
|
+
clearPane();
|
|
44
|
+
if (!surface.open) surface.showModal();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const syncMode = () => {
|
|
48
|
+
if (!surface.open || (app.panelPlacement("reminders") === "pane") === surface.classList.contains("is-pane")) return;
|
|
49
|
+
pendingReopen = true;
|
|
50
|
+
surface.close();
|
|
51
|
+
showSurface();
|
|
52
|
+
panelHeading.focus({ preventScroll: true });
|
|
53
|
+
};
|
|
54
|
+
const closeSurface = (focus = true) => {
|
|
55
|
+
restoreSurfaceFocus = focus;
|
|
56
|
+
if (surface.open) surface.close();
|
|
57
|
+
};
|
|
58
|
+
function openSurface() {
|
|
59
|
+
if (!roomId()) return;
|
|
60
|
+
if (app.panelPlacement("reminders") === "pane") app.closeDocPreview?.(false);
|
|
61
|
+
if (surface.open) { panelHeading.focus(); return; }
|
|
62
|
+
app.closePanels?.();
|
|
63
|
+
const active = document.activeElement;
|
|
64
|
+
opener = active instanceof HTMLElement && active !== document.body && !active.closest("dialog") && !$("#roomOptions")?.contains(active)
|
|
65
|
+
? active : $("#btnRoomOptions");
|
|
66
|
+
showSurface();
|
|
67
|
+
panelHeading.focus();
|
|
68
|
+
void load();
|
|
69
|
+
}
|
|
26
70
|
const current = (id, context) => roomId() === id && roomGeneration === context;
|
|
27
71
|
const invalidateLoads = () => { generation++; };
|
|
28
72
|
const errorText = (error) => error?.message || app.t("requestFailed", { status: error?.status || "?" });
|
|
@@ -140,18 +184,33 @@ export function initReminders(app) {
|
|
|
140
184
|
newButton.addEventListener("click", () => openDialog());
|
|
141
185
|
$("#btnCloseReminder").addEventListener("click", () => dialog.close());
|
|
142
186
|
$("#btnCancelReminder").addEventListener("click", () => dialog.close());
|
|
143
|
-
dialog.addEventListener("click", (event) => { if (event.target === dialog) dialog.close(); });
|
|
144
187
|
dialog.addEventListener("close", () => { editing = null; });
|
|
145
|
-
trigger.addEventListener("click", () => {
|
|
146
|
-
|
|
147
|
-
|
|
188
|
+
trigger.addEventListener("click", () => { app.closePanels(); openSurface(); });
|
|
189
|
+
$("#btnCloseReminders").addEventListener("click", () => closeSurface());
|
|
190
|
+
surface.addEventListener("cancel", (event) => { event.preventDefault(); closeSurface(); });
|
|
191
|
+
surface.addEventListener("close", () => {
|
|
192
|
+
if (pendingReopen) { pendingReopen = false; return; }
|
|
193
|
+
clearPane();
|
|
194
|
+
const focus = restoreSurfaceFocus;
|
|
195
|
+
restoreSurfaceFocus = true;
|
|
196
|
+
const target = opener;
|
|
197
|
+
opener = null;
|
|
198
|
+
if (focus && target?.isConnected) target.focus({ preventScroll: true });
|
|
199
|
+
});
|
|
200
|
+
document.addEventListener("keydown", (event) => {
|
|
201
|
+
if (event.key !== "Escape" || event.altKey || !surface.open || !surface.classList.contains("is-pane")) return;
|
|
202
|
+
if (!surface.contains(document.activeElement)) return;
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
closeSurface();
|
|
148
205
|
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
206
|
+
app.registerPanelSurface?.("reminders", { element: surface, close: (restore = false) => closeSurface(restore) });
|
|
207
|
+
app.watchPanel?.("reminders", syncMode);
|
|
208
|
+
const closePanels = app.closePanels;
|
|
209
|
+
app.closePanels = () => { closePanels(); if (dialog.open) dialog.close(); };
|
|
152
210
|
document.addEventListener("chat-room-activated", (event) => {
|
|
153
211
|
if (activeRoomId) drafts.set(activeRoomId, createDraft ?? formDraft());
|
|
154
212
|
if (dialog.open) dialog.close();
|
|
213
|
+
if (surface.open && !surface.classList.contains("is-pane")) closeSurface(false);
|
|
155
214
|
formStatus("");
|
|
156
215
|
editing = null; createDraft = null; saving = false; saveToken++; submit.disabled = false;
|
|
157
216
|
activeRoomId = event.detail; restoreDraft(drafts.get(activeRoomId));
|
|
@@ -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
|
};
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
// sniffs text and PDF uploads as application/octet-stream, so the filename
|
|
3
3
|
// extension is a first-class signal alongside the MIME type.
|
|
4
4
|
export const TEXT_PREVIEW_LIMIT = 2 * 1024 * 1024;
|
|
5
|
+
// Office files are zipped XML packages; the viewer needs far more room than text.
|
|
6
|
+
export const OFFICE_PREVIEW_LIMIT = 20 * 1024 * 1024;
|
|
7
|
+
export const OFFICE_KINDS = new Set(["docx", "xlsx", "pptx"]);
|
|
8
|
+
const OFFICE_MIMES = {
|
|
9
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
10
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
11
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
|
|
12
|
+
};
|
|
5
13
|
|
|
6
14
|
const MIME_LANGUAGES = {
|
|
7
15
|
"application/json": "json", "application/ld+json": "json",
|
|
@@ -65,6 +73,9 @@ export function docPreviewFormat(resource) {
|
|
|
65
73
|
if (mime === "text/markdown" || mime === "text/x-markdown" || ext === "md" || ext === "markdown") {
|
|
66
74
|
return { kind: "markdown", language: "", label: "" };
|
|
67
75
|
}
|
|
76
|
+
// Server sniffing reports Office packages as octet-stream, so the extension counts.
|
|
77
|
+
const office = OFFICE_MIMES[mime] || (OFFICE_KINDS.has(ext) ? ext : "");
|
|
78
|
+
if (office) return { kind: office, language: "", label: office.toUpperCase() };
|
|
68
79
|
const knownExtension = Object.hasOwn(EXTENSION_LANGUAGES, ext);
|
|
69
80
|
if (!knownExtension && !isTextMime(mime)) return null;
|
|
70
81
|
const language = knownExtension ? EXTENSION_LANGUAGES[ext] : MIME_LANGUAGES[mime] || "";
|
|
@@ -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
|
-
|
|
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
|
-
// Browser settings shared by the join page and the chat: language, theme, and the optional token.
|
|
2
|
-
export const THEMES = ["system", "light", "dark", "forest", "sand"];
|
|
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", "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.$;
|
|
@@ -8,21 +18,75 @@ export function initSettings(app) {
|
|
|
8
18
|
const tokenInput = $("#inTokenChat"), tokenHint = $("#tokenHint");
|
|
9
19
|
const contentInput = $("#inContentTransition");
|
|
10
20
|
const pageInput = $("#inPageStep"), pageValue = $("#pageStepValue");
|
|
21
|
+
const frameSelect = $("#inWindowFrame");
|
|
22
|
+
const panelInputs = [...dialog.querySelectorAll("[data-panel-mode]")];
|
|
23
|
+
if (document.body.dataset.integrationsAdmin !== "true") {
|
|
24
|
+
$("#settingsTabIntegrations")?.remove();
|
|
25
|
+
$("#settingsPanelIntegrations")?.remove();
|
|
26
|
+
}
|
|
11
27
|
const tabs = [...dialog.querySelectorAll('[role="tab"]')];
|
|
28
|
+
const customColorInput = $("#inCustomThemeColor");
|
|
12
29
|
const scheme = matchMedia("(prefers-color-scheme: dark)");
|
|
13
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
|
+
};
|
|
14
71
|
|
|
15
72
|
const syncThemeColor = () => {
|
|
16
73
|
const meta = document.querySelector('meta[name="theme-color"]');
|
|
17
|
-
const
|
|
74
|
+
const token = document.documentElement.dataset.windowFrame === "borderless" ? "--surface" : "--bg";
|
|
75
|
+
const background = document.documentElement.dataset.theme === "custom" ? customColor() : getComputedStyle(document.documentElement).getPropertyValue(token).trim();
|
|
18
76
|
if (meta && background) meta.content = background;
|
|
19
77
|
};
|
|
20
78
|
const syncThemeInputs = () => {
|
|
21
79
|
const stored = THEMES.includes(app.LS.theme) ? app.LS.theme : "system";
|
|
22
80
|
for (const input of dialog.querySelectorAll('input[name="theme"]')) input.checked = input.value === stored;
|
|
81
|
+
if (customColorInput) customColorInput.value = customColor();
|
|
82
|
+
};
|
|
83
|
+
const syncPanelInputs = () => {
|
|
84
|
+
for (const select of panelInputs) select.value = app.panelMode(select.dataset.panelMode);
|
|
23
85
|
};
|
|
24
86
|
const applyTheme = (value, persist) => {
|
|
87
|
+
clearCustomSchedules();
|
|
25
88
|
const theme = THEMES.includes(value) ? value : "system";
|
|
89
|
+
syncCustomColor();
|
|
26
90
|
document.documentElement.dataset.theme = theme;
|
|
27
91
|
if (persist) app.LS.theme = theme;
|
|
28
92
|
syncThemeInputs();
|
|
@@ -31,6 +95,16 @@ export function initSettings(app) {
|
|
|
31
95
|
app.setTheme = (value) => applyTheme(value, true);
|
|
32
96
|
app.settingsOpen = () => dialog.open;
|
|
33
97
|
|
|
98
|
+
const framePreference = () => app.LS.windowFrame === "borderless" ? "borderless" : "framed";
|
|
99
|
+
const applyWindowFrame = (mode, persist) => {
|
|
100
|
+
const preference = mode === "borderless" ? "borderless" : "framed";
|
|
101
|
+
document.documentElement.dataset.windowFrame = preference;
|
|
102
|
+
if (frameSelect) frameSelect.value = preference;
|
|
103
|
+
if (persist) app.LS.windowFrame = preference;
|
|
104
|
+
syncThemeColor();
|
|
105
|
+
};
|
|
106
|
+
app.setWindowFrame = (value) => applyWindowFrame(value, true);
|
|
107
|
+
|
|
34
108
|
// One tab stop for the whole tablist; arrow keys move selection like a native tab widget.
|
|
35
109
|
const activateTab = (name, { focus = false } = {}) => {
|
|
36
110
|
for (const tab of tabs) {
|
|
@@ -41,6 +115,7 @@ export function initSettings(app) {
|
|
|
41
115
|
if (panel) panel.hidden = !selected;
|
|
42
116
|
if (selected && focus) tab.focus();
|
|
43
117
|
}
|
|
118
|
+
if (name === "integrations") app.loadIntegrations?.();
|
|
44
119
|
};
|
|
45
120
|
const onTabKey = (event) => {
|
|
46
121
|
const index = tabs.indexOf(event.target);
|
|
@@ -59,6 +134,8 @@ export function initSettings(app) {
|
|
|
59
134
|
const open = ({ token = false } = {}) => {
|
|
60
135
|
app.closePanels?.();
|
|
61
136
|
syncThemeInputs();
|
|
137
|
+
syncPanelInputs();
|
|
138
|
+
applyWindowFrame(framePreference(), false);
|
|
62
139
|
if (contentInput) contentInput.checked = app.LS.contentTransition;
|
|
63
140
|
if (pageInput) pageInput.value = String(app.LS.pageStep);
|
|
64
141
|
if (pageValue) pageValue.textContent = `${app.LS.pageStep}%`;
|
|
@@ -87,15 +164,31 @@ export function initSettings(app) {
|
|
|
87
164
|
dialog.close();
|
|
88
165
|
};
|
|
89
166
|
$("#btnCloseSettings")?.addEventListener("click", close);
|
|
90
|
-
dialog.addEventListener("click", (event) => { if (event.target === dialog) close(); });
|
|
91
167
|
dialog.addEventListener("cancel", () => opener?.setAttribute("aria-expanded", "false"));
|
|
92
168
|
pageInput?.addEventListener("input", () => {
|
|
93
169
|
app.LS.pageStep = pageInput.value;
|
|
94
170
|
pageInput.value = String(app.LS.pageStep);
|
|
95
171
|
if (pageValue) pageValue.textContent = `${app.LS.pageStep}%`;
|
|
96
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
|
+
});
|
|
97
186
|
dialog.addEventListener("change", (event) => {
|
|
98
187
|
if (event.target instanceof HTMLInputElement && event.target.name === "theme") app.setTheme(event.target.value);
|
|
188
|
+
if (event.target === frameSelect) app.setWindowFrame(frameSelect.value);
|
|
189
|
+
if (event.target instanceof HTMLSelectElement && event.target.dataset.panelMode) {
|
|
190
|
+
app.setPanelMode(event.target.dataset.panelMode, event.target.value);
|
|
191
|
+
}
|
|
99
192
|
if (event.target === contentInput) app.LS.contentTransition = contentInput.checked;
|
|
100
193
|
if (event.target === pageInput) {
|
|
101
194
|
app.LS.pageStep = pageInput.value;
|
|
@@ -114,4 +207,5 @@ export function initSettings(app) {
|
|
|
114
207
|
scheme.addEventListener("change", () => { if (app.LS.theme === "system") syncThemeColor(); });
|
|
115
208
|
|
|
116
209
|
applyTheme(app.LS.theme, false);
|
|
210
|
+
applyWindowFrame(framePreference(), false);
|
|
117
211
|
}
|
|
@@ -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,19 +1,20 @@
|
|
|
1
1
|
// Resizes the right-hand pane (Markdown preview or task board) on wide windows.
|
|
2
|
-
// --side-pane-width holds the only width;
|
|
3
|
-
//
|
|
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 =
|
|
11
|
+
const MAX_WIDTH = 1080;
|
|
12
|
+
const ANIMATION_MS = 220;
|
|
11
13
|
|
|
12
14
|
export function initSidePaneSplitter(app) {
|
|
13
15
|
const view = app.$("#chatView");
|
|
14
16
|
const handle = app.$("#sidePaneHandle");
|
|
15
17
|
const preview = app.$("#docPreview");
|
|
16
|
-
const tasks = app.$("#tasksDialog");
|
|
17
18
|
if (!view || !handle) return;
|
|
18
19
|
|
|
19
20
|
let stored = readStored();
|
|
@@ -21,9 +22,23 @@ export function initSidePaneSplitter(app) {
|
|
|
21
22
|
let frame = 0;
|
|
22
23
|
let pending = 0;
|
|
23
24
|
let drag = null;
|
|
25
|
+
let paneWasOpen = view.classList.contains("has-doc") || view.classList.contains("has-pane");
|
|
26
|
+
let animationTimer = 0;
|
|
24
27
|
|
|
25
28
|
const activePane = () => view.classList.contains("has-doc") ? preview
|
|
26
|
-
: view.classList.contains("has-
|
|
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
|
+
};
|
|
27
42
|
|
|
28
43
|
// A wide task board must leave the conversation a full working column; the
|
|
29
44
|
// Markdown preview keeps the normal minimum.
|
|
@@ -42,7 +57,9 @@ export function initSidePaneSplitter(app) {
|
|
|
42
57
|
handle.setAttribute("aria-valuemax", String(Math.round(maxWidth())));
|
|
43
58
|
const pane = activePane();
|
|
44
59
|
if (pane?.open) {
|
|
45
|
-
|
|
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)));
|
|
46
63
|
}
|
|
47
64
|
};
|
|
48
65
|
|
|
@@ -56,7 +73,7 @@ export function initSidePaneSplitter(app) {
|
|
|
56
73
|
// attribute changes when the workspace first appears.
|
|
57
74
|
const reflow = () => {
|
|
58
75
|
if (!view.clientWidth) return;
|
|
59
|
-
if (stored == null) syncAria();
|
|
76
|
+
if (stored == null) { applied = 0; syncAria(); }
|
|
60
77
|
else apply(clamp(stored));
|
|
61
78
|
};
|
|
62
79
|
|
|
@@ -109,7 +126,7 @@ export function initSidePaneSplitter(app) {
|
|
|
109
126
|
|
|
110
127
|
handle.addEventListener("keydown", (event) => {
|
|
111
128
|
if (!activePane()?.open) return;
|
|
112
|
-
const current = activePane().getBoundingClientRect().width;
|
|
129
|
+
const current = applied || activePane().getBoundingClientRect().width;
|
|
113
130
|
const step = event.shiftKey ? 64 : 16;
|
|
114
131
|
let next;
|
|
115
132
|
if (event.key === "ArrowRight") next = current - step;
|
|
@@ -123,13 +140,20 @@ export function initSidePaneSplitter(app) {
|
|
|
123
140
|
|
|
124
141
|
handle.addEventListener("dblclick", () => {
|
|
125
142
|
stored = null;
|
|
143
|
+
applied = 0;
|
|
126
144
|
try { localStorage.removeItem(STORAGE_KEY); } catch { /* Ignore unavailable storage. */ }
|
|
127
145
|
view.style.removeProperty("--side-pane-width");
|
|
128
146
|
syncAria();
|
|
129
147
|
});
|
|
130
148
|
|
|
131
|
-
window.addEventListener("resize",
|
|
132
|
-
|
|
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"] });
|
|
133
157
|
reflow();
|
|
134
158
|
}
|
|
135
159
|
|