Repository navigation
feat(web): per-instance display name (CODEG_INSTANCE_NAME) + server-side client preferences API - #1000
Open
unixcs wants to merge 3 commits into
Open
feat(web): per-instance display name (CODEG_INSTANCE_NAME) + server-side client preferences API#1000unixcs wants to merge 3 commits into
unixcs wants to merge 3 commits into
Conversation
added 3 commits
October 20, 2026 17:29
Instance name (CODEG_INSTANCE_NAME env): - Rewrites served HTML <title> and the client-side ' - codeg' suffix, plus manifest.json name/short_name, at the static-serving layer. The build artifacts stay byte-identical to upstream, so rebasing the fork or self-updating never loses the per-deployment name (PWA installs on the same phone need distinct labels per server). Client preferences (get_client_preferences / update_client_preferences): - Opaque JSON blob (schema owned by frontend) in the app_metadata KV. - Web frontend seeds localStorage from the server on hydration (new browser / cleared site data self-heals), pushes local state up when the server is empty (first configured browser becomes the seed), and dual-writes changes debounced; cross-window storage events re-enter local state without re-pushing (echo guard). Desktop/Tauri skipped. - Floating-ball settings (enabled/position/bindings/size/favorites) are the first synced blocks; cross-server reconciliation is handled outside the server by a loopback agent + timer. # Conflicts: # src/components/appearance-provider.tsx
…client-prefs # Conflicts: # src-tauri/src/web/handlers/mod.rs
Handing back the raw app_metadata row made clients parse
{"prefs":"…","synced_at_ms":N} as their own blob, find no keys, conclude
"server has nothing" and push their local copy — the server never seeded
anyone. GET now unwraps the envelope (legacy nested rows included) and PUT
normalises on write, so a single bad import cannot wedge the row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two server-side additions that make self-hosted multi-instance deployments friendlier. Both are opt-in / additive; default behavior is byte-identical to current main.
1. Per-instance display name —
CODEG_INSTANCE_NAMEenvSelf-hosters running several codeg servers (e.g. one per machine) all get identical tab titles and identical PWA names (
codeg) when installed to a phone home screen — indistinguishable icons.Setting
CODEG_INSTANCE_NAME=Tencent-codegrewrites at the static-serving layer:<title>in served HTML (codeg→Tencent-codeg, and the client-side- codegsuffix →- Tencent-codeg, including the RSC payload)manifest.jsonname/short_name(JSON-aware, escaped)Key property: build artifacts stay byte-identical to upstream. The name lives in deployment config, not in the bundle — rebasing a fork or using the built-in self-updater never loses it.
Implementation: a small axum middleware (
src-tauri/src/web/instance_name.rs) that buffers HTML/manifest responses (8 MB cap), rewrites, fixesContent-Length. Invalid/empty values are ignored (falls back to stock naming). 8 unit tests included.2. Server-side client preferences KV —
get_client_preferences/update_client_preferencesFloating-ball / appearance settings currently live only in
localStorage, so a new browser, cleared site data, or a different machine starts from zero every time.These two all-POST endpoints (Bearer auth, same as the rest of
/api) store one opaque JSON blob ({"prefs": "<json>", "synced_at_ms": N}) in the existingapp_metadataKV table:The web frontend wiring (hydrate-on-load, debounced dual-write, echo guard) lives in our fork and is not part of this PR; cross-server reconciliation is intentionally outside the server, done by a loopback agent + timer that replays the winning blob between nodes. 4 unit tests for the handlers.
Testing
cargo test --lib --no-default-features --features server-bin— 12 new tests greenin-syncevery 5 min