Skip to content

feat: report the state changes worth interrupting a user for - #40

Merged
fylorn merged 1 commit into
mainfrom
feat/notice-signals
Sep 17, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/notice-signals

Conversation

@fylorn

@fylorn fylorn commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Groundwork for desktop notifications. The desktop app decides whether to raise one, so what it needs from core is state transitions — reported once when they happen, and again when they recover. Three were missing, and for the same reason each time: nothing in core was in a position to notice.

Event Why it did not exist When it fires
ProxyChanged A proxy failure and an upstream failure are indistinguishable at the reqwest layer, so a dead proxy looked like "several upstreams are down at once" A request that cannot connect through a named proxy checks that proxy once (the L1 handshake, not a poll, re-checked at most every 30s); a later success through it reports that it is back
AuthChanged 401/403 is not a failure for the circuit breaker — retrying elsewhere would be rejected too — so a stale key never trips it and never surfaces On the transition into rejection with the status, and again when the upstream accepts the credential
StorageChanged The disk level already changed what the recorder writes, and only wrote a log On a level change, with the free space

ConfigRejected also carries origin now, so the interface can tell a typo in the user's editor from a write it just made itself — the second one is a failed save, and that path reports itself.

Notes

  • No polling anywhere: the proxy check is reactive, and every other signal rides traffic that already happens.
  • Recovery matters as much as failure here: a notification that cannot be withdrawn is a notification users turn off.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace --no-fail-fast
    • New tw-gateway/tests/notices.rs: an upstream that rejects the credential is reported once and again on recovery; a proxy that drops connections is named as the cause and reported again when it comes back (a fake proxy that speaks both absolute-form and CONNECT, so the same process serves forwarding and the check)
    • tw-store: a level change is announced once, not repeated within a level, and announced again on the way back
    • tw-control: the rejection carries external when the file was edited outside the app
  • ./scripts/smoke.sh: 48 passed, 0 failed

🤖 Generated with Claude Code

The desktop app decides whether to raise a system notification, so what it
needs from core is state transitions, each reported once and again when it
recovers. Three signals were missing, and the reason they were missing is
the same in every case: nothing in core was in a position to notice.

- ProxyChanged: a request that cannot connect through a named proxy now
  checks that proxy once (the L1 handshake, not a poll), and a failure is
  reported against the proxy rather than against every upstream behind it.
  Re-checks are spaced 30s apart and a success through the proxy reports
  that it is back.
- AuthChanged: a 401 or 403 from an upstream is not a failure for the
  circuit breaker (retrying elsewhere would be rejected too), so a stale
  key never trips it and never reaches the user. It is reported on the
  transition, and again when the upstream accepts the credential.
- StorageChanged: the disk level already changed the recorder's behaviour
  and only wrote a log. A request with no body is otherwise indistinguishable
  from a bug.

ConfigRejected now carries the origin, so the interface can tell a typo in
the user's editor from a write it just made itself.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Thanks for the PR. One thing before review: this targets main, and it should target dev.

main is a release-only line — branch-protected, linear history, and every commit on it is a tagged release snapshot. Routine work lands on dev and reaches main with the next release. GitHub pre-filled main here because it is the default branch, so this is our defaults being unhelpful rather than anything you did wrong.

No need to close and reopen: click Edit next to the PR title and change the base branch to dev. The commits and the discussion carry over.

See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract.

@fylorn
fylorn merged commit 80cfc5d into main Sep 17, 2026
2 checks passed
@fylorn
fylorn deleted the feat/notice-signals branch September 17, 2026 19:06
@fylorn fylorn mentioned this pull request Sep 17, 2026
fylorn added a commit that referenced this pull request Sep 17, 2026
The state changes worth interrupting a user for (#40): a dead proxy, an
upstream that rejects the credential, and the disk level.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant