Repository navigation
Add remote Settings and control API (1.2.0) - #22
Merged
sdas92 merged 20 commits intoNov 27, 2026
Merged
Conversation
Describe the API contract, cross-process config ownership, restart orchestration, and key migration; record ADR 0002 and add glossary terms for Settings, Revision, Scope, API key, and Restart.
Add POST /api/webhook/test, which sends a test Webhook to a candidate target and secret without changing live Settings. The call is offloaded from the event loop, never follows redirects, and scrubs URL parts from errors. Covered against a local HTTP receiver.
Read Webhook timeout, maximum attempts, backoff, and Outbox capacity from the live Settings on each Delivery attempt and at enqueue. Missing or invalid values fall back to today's constants, a malformed Settings file cannot crash the dispatcher, and explicit constructor overrides still win.
Add regression coverage for remote Webhook and retry changes surviving a stale local save, and for invalid stale forms leaving Settings unchanged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bump the app version and changelog to 1.2.0, document the remote Settings and control API in the README, and refresh version references.
Move both text fields out of MDListItem's trailing slot into full-width rows so long Webhook targets are editable on Android.
Remove unused key adapters, share the health uptime calculation, rename the dispatcher override helper, reuse the default Webhook shape on reset, and refresh the remote API docs. Drop the no-op release-workflow comment edits.
Write resp.json atomically, give Restart intents an id so a later request is not suppressed, stop persisting a v1 key migration on launch, use only the documented key owner marker, document next-launch boot semantics, and replace private restart state in tests with a clock patch.
There was a problem hiding this comment.
🟡 Changes recommended
Webhook URL validation accepts missing hostnames and invalid ports, allowing enabled forwarding to fail and discard queued SMS after retries are exhausted.
7 open issues
Validate the Webhook target hostname and port · New Capture the exception message before scheduling the callback · New Preserve unsaved port edits after saving Webhook settings · New Refresh the UI when a restart changes the bound port · New Detect the live CLI server port when checking restart requirements · New Normalize the timeout used by the remote Webhook test · New Handle restart requests when the CLI has no restart consumer · New
What changed in this PR
Adds remote Settings and control to OpenSMS’s existing bearer-authenticated FastAPI server for version 1.2.0, alongside scoped API keys and live Webhook retry settings.
Changes:
- Adds Settings, health, status, Webhook test, Restart, and key-management endpoints.
- Introduces shared persistence services and updates the on-device UI to preserve remote changes.
- Expands automated tests, adds Linux test CI, and documents the API and migration behavior.
| File | Description |
|---|---|
| README.md | Documents remote API usage, scopes, and network precautions. |
| GLOSSARY.md | Defines Settings, Revision, Scope, API key, and Restart. |
| docs/webhook/receiver_test.md | Updates the example User-Agent version. |
| docs/remote-api.md | Specifies API contracts, persistence, and operational behavior. |
| docs/adr/0002-remote-settings-and-control-api.md | Records remote-control architecture and tradeoffs. |
| docs/adr/0001-inbound-sms-webhook.md | Documents live retry and capacity settings. |
| CHANGELOG.md | Adds the 1.2.0 release notes. |
| app/tests/test_webhook.py | Tests live retry settings and credentialed-target rejection. |
| app/tests/test_settings_local_save.py | Tests local merges, validation, and remote-change preservation. |
| app/tests/test_key_svc.py | Tests key persistence, migration, and concurrent mutations. |
| app/tests/test_control_svc.py | Tests Restart intents, normalization, and port resolution. |
| app/tests/api_test_case.py | Adds isolated HTTP test setup and key helpers. |
| app/services/webhookSvc.py | Applies live retry settings and target credential handling. |
| app/services/settingsSvc.py | Adds shared Settings validation, revisions, and atomic persistence. |
| app/services/postApi.py | Adds remote endpoints, scoped authentication, and runtime reporting. |
| app/services/netSvc.py | Allows status reporting to distinguish network discovery failures. |
| app/services/keySvc.py | Implements named keys, migration, scopes, and locked persistence. |
| app/services/controlSvc.py | Implements atomic control intents and effective-port resolution. |
| app/services/config.py | Bumps the application version to 1.2.0. |
| app/services/appSvc.py | Handles Restart intents and provides live runtime status. |
| app/screens/settings.py | Updates key-rotation wording and Webhook input layout. |
| app/requirements-dev.txt | Adds test-only HTTP client dependency. |
| app/openSmsCli.py | Clarifies phone-key replacement prompts. |
| app/main.py | Merges local Settings edits and refreshes persisted values. |
| .github/workflows/tests.yml | Adds Linux unit-test automation. |
Review effort: Balanced
Reject Webhook targets without a hostname or with an invalid port; capture the Settings error message before scheduling the toast; keep unsaved port edits on a Webhook-only save; publish the bound port so the UI refreshes after a Restart; fall back to the live server port for restart_required; normalize the Webhook-test timeout; reject Restart when no consumer is registered.
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
Expose Settings and control over the existing bearer-authenticated FastAPI server, add named API keys with scopes, make Webhook retry policy live Settings, and keep the on-device UI in step with remote writes.
New surface: GET /api/health, GET /api/status, GET/PUT /api/settings, POST /api/webhook/test, POST /api/server/restart, and GET/POST/DELETE /api/keys. POST /sms/ is unchanged.
Evidence
python -m unittest discover -s tests -p "test_*.py".Merge Danger
Door: two-way for the code; one-way for existing installs because keys.json v1 -> v2 and the new Settings revision are persisted.
Blast Radius: auth, Settings, and Webhook delivery.