Repository navigation
fix: save download settings changed over the REST API - #644
Merged
Merged
Conversation
PUT /api/config only applied a change in memory, so settings a phone changed on a `ketch server` or on a desktop or Android app sharing its engine were lost when that device restarted, and the apps said "until it restarts". KetchServer takes an onConfigChanged hook, which PUT /api/config calls, one request at a time, once DestinationGuard and updateConfig accepted the body; a failed save answers 500 config_not_saved. Servers with the hook list config.persisted (KetchFeatures.CONFIG_PERSISTED). - ketch server saves the [download] fields a change sets over what its config.toml holds (ServerConfigFile), creating the file when missing, so values from flags, KETCH_* variables and defaults stay out of it; fields those set are saved with a warning, as they win at the next start. - The apps' shared servers and the desktop's LocalApiServer save through InstanceManager.sharedConfigChanged, which hands the change to the app's settings (InstanceSettingsController.acceptShared): saved with the standing speed cap, never a Slow lane, and shown on the Settings page. - The Downloads and Speed pages of a device listing config.persisted say its changes are saved there; older servers keep the old notice.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Temporary folders are in /tmp on Linux, which createTestServer allows, so the folder the test expected the server to refuse was allowed there.
Contributor
Test Results 2 213 files + 5 2 241 suites +5 57m 39s ⏱️ -22s Results for commit 30e6122. ± Comparison against base commit 18d1de8. This pull request removes 1 and adds 28 tests. Note that renamed tests count towards both.This pull request removes 1 skipped test and adds 1 skipped test. Note that renamed tests count towards both. |
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.
Summary
PUT /api/configonly applied a change in memory:ketch servernever wrote its config.toml, and a desktop or Android app sharing its engine never saved a phone's change to its own config.toml or its Settings. Download and Speed settings changed from another device were lost on that device's restart, and the apps said "Saved on X until it restarts".KetchServer(onConfigChanged = …).PUT /api/configruns one request at a time and calls the hook onceDestinationGuardandupdateConfigaccepted the body; a failed save answers500 config_not_saved(the change still applies until a restart). Servers with the hook addconfig.persisted(KetchFeatures.CONFIG_PERSISTED, not inALL) to/api/status.ketch server:ServerConfigFilesaves to[download]of the--configfile, else the default one (created when missing, e.g. Docker's/config/config.toml). Only the fields a change sets to a new value are written over what the file holds then, so values from flags,KETCH_*variables and defaults stay out of it and hand edits are kept. A field a flag or variable sets is saved too, with a warning, since that flag or variable wins at the next start. An unreadable file is never overwritten; the next change retries the failed fields.LocalServerContextwhoseonConfigChangedisInstanceManager.sharedConfigChanged(the desktop'sLocalApiServertoo, forketch mcpand friends).AppStateregisters a handler that runsInstanceSettingsController.acceptShared: saved throughAppSettingsController.saveDownloadwithsavedSpeedLimit, so a Slow lane never becomes the standing cap, and shown on the Settings page, unless an edit made there was accepted since. Without a handler (app UI closed), the manager saves[download]straight to the store.config.persistedsay "Saved on X." (translated); older servers keep "until it restarts". The Network page's "Resets when X restarts" stays, as interface selection is runtime-only by design.ketch server),cli/README.md(new "Settings clients change"), Docker (en, zh-CN), API and developer docs.Note: saving rewrites config.toml through
FileConfigStore, so comments from--generate-configare dropped on the first save, as the apps already do.Snapshots (remote NAS device)
Testing
:library:server:test: hook called with what the instance applied, not called whenupdateConfigorDestinationGuardrejects,config_not_savedkeeps the change applied,config.persistedonly with a hook:cli:test:ServerConfigFileTest(changed field only, other sections, hooks and Windows backslashes kept; missing file created without env values; edits kept; unreadable file left alone and retried; pinned field names):app:shared:jvmTest(all),:app:desktop:test,:app:shared:compileTestKotlinIosSimulatorArm64,:app:shared:compileKotlinWasmJs,:app:android:compileDirectDebugKotlin,:library:api:updateKotlinAbi