Repository navigation
feat: run speed modes on the device that downloads - #646
Merged
Merged
Conversation
The Slow lane and Auto rules were applied by the app to its embedded engine only, so a phone could give a NAS a plain speed limit and nothing more, and a schedule would stop as the phone slept. The engine now runs them itself, and every device's Speed settings offer them. - library:api: SpeedModes (a ControlKey controller), SpeedModeState, SpeedModeChange, Interest.SpeedMode and the speed.modes feature; the [speed] types and SpeedScheduler move here from config and the app. - library:core: Ketch(speedModes = SpeedModeOptions(...)) runs them over its global limit (SpeedModeKeeper): rules evaluated as they start and end, the observed peak recorded from its own tasks, and the standing cap kept current, also through updateConfig. - REST GET/PUT /api/speed, the event stream's speedMode interest and RemoteKetch.controller(SpeedModes), which fails closed on older servers. - ketch server runs [speed] and saves changes back to its config file. - Apps: the hosts hand the speed modes to their engine; InstanceManager keeps a SpeedModeController per device, so the Speed page, the Pulse pill and popover, device menus and DevicePresence work for remote devices too. Older devices keep the plain limit and their note. Design: docs/plans/speed-modes.md.
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. |
Contributor
Test Results 2 217 files + 9 2 245 suites +9 56m 58s ⏱️ - 1m 3s Results for commit 0e7ddd4. ± Comparison against base commit 18d1de8. This pull request removes 82 and adds 160 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
- KetchSpeedModesTest names a download folder, as Android host tests cannot resolve the default one. - SpeedSchedulerTest runs on the JVM: Node.js has no time zones but UTC unless js-joda's database is loaded. - ServerSpeedModesTest uses runBlocking, so an exception another CLI test leaks no longer fails it.
linroid
enabled auto-merge (squash)
October 24, 2026 06:58
# Conflicts: # AGENTS.md # app/shared/src/commonMain/composeResources/values-de/strings_settings.xml # app/shared/src/commonMain/composeResources/values-es/strings_settings.xml # app/shared/src/commonMain/composeResources/values-fr/strings_settings.xml # app/shared/src/commonMain/composeResources/values-ja/strings_settings.xml # app/shared/src/commonMain/composeResources/values-ko/strings_settings.xml # app/shared/src/commonMain/composeResources/values-pt/strings_settings.xml # app/shared/src/commonMain/composeResources/values-ru/strings_settings.xml # app/shared/src/commonMain/composeResources/values-zh-rTW/strings_settings.xml # app/shared/src/commonMain/composeResources/values-zh/strings_settings.xml # app/shared/src/commonMain/composeResources/values/strings_settings.xml # app/shared/src/commonMain/kotlin/com/linroid/ketch/app/ui/settings/SpeedSettingsPage.kt # app/shared/src/jvmTest/kotlin/com/linroid/ketch/app/snapshot/SampleData.kt # library/api/src/commonMain/kotlin/com/linroid/ketch/api/KetchFeatures.kt
# Conflicts: # AGENTS.md # app/shared/src/commonMain/kotlin/com/linroid/ketch/app/state/AppState.kt # app/shared/src/iosMain/kotlin/com/linroid/ketch/app/MainViewController.kt # app/shared/src/jvmTest/kotlin/com/linroid/ketch/app/snapshot/SettingsDeviceSnapshots.kt # cli/src/main/kotlin/com/linroid/ketch/cli/Main.kt
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
Full speed, the Slow lane and Auto rules ran in the app and drove only the embedded engine, so the Speed page offered a remote device a plain speed limit ("No Slow lane or Auto for it yet."), and a phone that sleeps could not keep a NAS on a schedule. Now the engine of the device doing the downloads runs them, and every device's Speed page offers them.
Design: docs/plans/speed-modes.md.
SpeedModes(aControlKeycontroller:state(),update(SpeedModeChange)),SpeedModeState,Interest.SpeedModeandKetchFeatures.SPEED_MODES(speed.modes).SpeedSettings,SpeedRule,SpeedLimitModeandWeekdaymove here fromconfig, andSpeedSchedulerfrom the app;[speed]reads as before.Ketch(speedModes = SpeedModeOptions(...))runs them over its global limit (SpeedModeKeeper): the rules re-evaluated as they start and end, the observed peak recorded from its own tasks, the standing cap kept current, also throughupdateConfig(another limit sets the cap; writing back the config read changes nothing).GET/PUT /api/speed, the event stream'sspeedModeinterest, andRemoteKetch.controller(SpeedModes), which fails closed against older servers.ketch serverruns[speed]and saves changes back to its config file (the cap as[download] speedLimitonly once it differs from the one a flag or env var gave it).embeddedSpeedModes), so the app-sideSpeedModeControllerbecomes a view of any device'sSpeedModes.InstanceManagerkeeps one per connected device; the Speed page reads a device the app does not keep connected once. The Speed page, Pulse pill and popover, device menus, palette, desktop menu bar andDevicePresence.speedModework for remote devices; devices on an older Ketch keep the plain limit and their note.A phone connected to
ketch servercan now switch it to Slow lane or Auto with rules, and the server follows them while the phone is offline (RemoteSpeedModesTestcovers that end to end).Snapshots
Speed settings of a remote device (NAS-Basement):
Phone:
Testing
SpeedModeKeeperTest(virtual time: rules starting and ending, cap, slow lane suggestion, peak, saving),KetchSpeedModesTest,SpeedSchedulerTest(moved).RemoteSpeedModesTest: a client switches a realKetchServerto Slow lane and Auto, which the server applies and saves; it follows the interest; older servers fail closed and answer404.ServerSpeedModesTest(CLI saving), appSpeedModeControllerTest,SpeedSettingsModelTest(embedded, remote, unconnected remote, older remote),DeviceActionsTest,DevicePresenceTest,SpeedModeActionsTest, desktopDesktopCommandsTest../gradlew allJvmTestspasses; CLI, core JS/WasmWasi, web, Android and iOS compile;checkKotlinAbiupdated.Notes
ketch mcp --standalonestill runs without speed modes.With #644 (saved download settings)
PUT /api/confighandsonConfigChangedthe standing cap rather than the limit in effect, which is the slow lane's while it holds, so no server saves it as the cap.ketch serversaves its speed modes throughServerConfigFile.update, under the locksavetakes, so neither write drops the other's; a flag orKETCH_SPEED_LIMITpinning the cap is warned about assavedoes.speed.modesandconfig.persisted.