Conversation
ee130ca to
9a3b4d8
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for configuring a custom DB-sync server base URL (persisted in localStorage) to enable self-hosted sync servers, and adjusts runtime URL derivation for both HTTP and WebSocket sync endpoints. It also updates snapshot streaming to avoid double-gzip decompression issues when fetch() auto-decompresses but leaves the content-encoding: gzip header intact.
Changes:
- Add a new “Sync server URL” advanced setting (desktop + mobile) and a dialog to save/reset the custom URL; immediately pushes updated sync config to the DB worker.
- Replace compile-time DB-sync URL constants with runtime functions that derive WS/HTTP URLs from the optional custom base.
- Simplify
response-body-streamto always useresp.bodyand update tests to match real-worldfetch()decompression behavior.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/frontend/config.cljs | Adds custom sync server URL persistence + URL derivation helpers and runtime getters for WS/HTTP bases. |
| src/main/frontend/components/settings.cljs | Adds desktop settings row + dialog UI; pushes updated sync config to worker. |
| src/main/mobile/components/settings.cljs | Adds mobile settings entry that opens the same dialog and shows current/default URL. |
| src/main/frontend/handler/events/ui.cljs | Adds event handler to open the sync server settings dialog. |
| src/main/frontend/handler/user.cljs | Updates rtc-group? gating to allow RTC when a custom sync server is configured. |
| src/main/frontend/persist_db/browser.cljs | Updates worker init to call runtime URL getters. |
| src/main/frontend/components/repo.cljs | Updates worker sync-config setup to call runtime URL getters. |
| src/main/frontend/handler/db_based/sync.cljs | Uses runtime sync base getters; simplifies response body streaming to avoid double-decompression. |
| src/main/frontend/spec/storage.cljc | Adds local-storage spec entry for the sync server URL key. |
| src/resources/dicts/en.edn | Adds i18n strings for the new sync server URL settings UI. |
| src/test/frontend/config_test.cljs | Adds unit tests for URL normalization/derivation helpers and defaults. |
| src/test/frontend/handler/db_based/sync_test.cljs | Updates snapshot streaming test to reflect real-world fetch() auto-decompression behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "Return true when `url` looks like a valid HTTP(S) base URL." | ||
| [url] | ||
| (and (string? url) | ||
| (re-find #"^https?://" url))) |
There was a problem hiding this comment.
valid-sync-server-url? is currently a simple regex prefix check, which will accept strings like "https://" (no host) and other malformed URLs that will later fail at fetch/WebSocket time. Consider validating via js/URL parsing (and ensuring protocol is http/https and hostname is present) so the UI can reliably reject invalid inputs.
| "Return true when `url` looks like a valid HTTP(S) base URL." | |
| [url] | |
| (and (string? url) | |
| (re-find #"^https?://" url))) | |
| "Return true when `url` is a syntactically valid HTTP(S) base URL | |
| with a non-empty hostname." | |
| [url] | |
| (when (string? url) | |
| (try | |
| (let [u (js/URL. url) | |
| protocol (.-protocol u) | |
| hostname (.-hostname u)] | |
| (and (#{"http:" "https:"} protocol) | |
| (seq hostname))) | |
| (catch :default _ | |
| false)))) |
9a3b4d8 to
f338fed
Compare
|
@tiensonqin I rebased my branch on current master. I removed the commit 9a3b4d8 as you fixed it on master. |
|
@hoellen Sorry for the late reply, I still have some work to finish on sync, mostly to ensure client/server checksum matches. I'll check this PR asap. |
f338fed to
7898280
Compare
tiensonqin
left a comment
There was a problem hiding this comment.
QAed on web/mobile/desktop apps, works great! 🚢 👍
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
5bf6109 to
b508034
Compare
* Add custom sync server Co-authored-by: Tienson Qin <tiensonqin@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Mirror the Custom Sync Server URL pattern (logseq#12459) for the single-page publish service. Settings -> Advanced -> Publish server URL opens a dialog that writes the URL to localStorage; frontend.config/publish-api-base reads it on each call so URL changes take effect without a restart. Unlike sync, publish does not need a push-config-to-worker step because the handler is purely HTTP request-response with no long-lived connection.
This PR adds a setting to configure a custom sync server URL for self-hosted sync. The URL is persisted in
localStorageand used to derive both the WebSocket and HTTP base URLs at runtime, replacing the previous compile-time constants.What changed
handler/user.cljs:rtc-group?returnstruewhen a custom sync server is configured, bypassing group membership checks. Self-hosted servers don't enforce group membership, so this is intentional.Tests
config_test.cljs.