Skip to content

feat(idlewatcher): add sleep/wake notification config - #20

Open
taljaards wants to merge 4 commits into
yusing:mainfrom
taljaards:feat/idlewatcher-sleep-notifications
Open

taljaards wants to merge 4 commits into
yusing:mainfrom
taljaards:feat/idlewatcher-sleep-notifications

Conversation

@taljaards

@taljaards taljaards commented Sep 9, 2026

Copy link
Copy Markdown

Mirrors yusing/godoxy#264, which adds opt-in sleep/wake notifications for idlesleep routes. Without the type and schema update the config editor rejects the new keys, since every generated schema sets additionalProperties: false.

Changes

  • config/config.tsdefaults.idlewatcher.notify, the global opt-in.
  • providers/idlewatcher.ts — the notify event vocabulary, plus the three flat proxy.idle_notify* Docker labels for DockerRoutes.
  • src/lib/api.ts — regenerated from the swagger in the backend PR. Purely additive: IdlewatcherNotifyConfig, IdlewatcherNotifyEvent, and notify on IdlewatcherConfig.
  • config.schema.json, routes.schema.json, docker_routes.schema.json — regenerated.

Stacking

Based on #19 (stale schema regeneration), so this diff stays limited to my own changes. Merge #19 first; until then this PR shows both commits.

Merge order

The backend PR regenerates swagger.json, which is the input for api.ts here. They can merge in either order — nothing breaks in between, the editor just won't accept the new keys until this one lands.

Verification

Generators run via npx rather than bunx (no bun on my machine — same tools, same flags). Both reproduce the committed output byte-for-byte on unchanged input, which is what makes the diffs trustworthy.

Validated the generated schemas against real config shapes with ajv:

  • defaults.idlewatcher.notify accepts enabled/to/events, and rejects unknown events and unknown keys
  • the proxy.idle_notify* Docker labels accept the documented forms

Note on the route-level case, pre-existing

routes.schema.json gains notify, but route-level idlewatcher: in file-provider YAML does not validate today regardless: routes.ts uses the swagger-generated IdlewatcherConfig, where every field is required and idle_timeout is a nanosecond int enum, so even idlewatcher: {idle_timeout: 30m} fails. I verified this fails identically before and after this PR.

The fix is presumably to give the nested route config a hand-written type with Duration strings, the way healthcheck already has — Partial<> alone is not enough because of the duration typing. That is a behaviour change for all existing idlewatcher fields, so I left it out and am flagging it instead. Happy to do it as a follow-up if you want it. It may be the same thing as the //FIXME: fix this on DockerRoutes.

🤖 Generated with Claude Code

Note

Add sleep/wake notification config to idle-watcher

  • Adds an IdlewatcherNotifyConfig interface with an enabled flag and a list of notification provider names
  • Adds idle_notify and idle_notify_to properties to IdleWatcherConfig in idlewatcher.ts, supporting Docker label mappings for comma-separated provider targets
  • Adds an optional defaults.idlewatcher.notify section in config.ts for route-level notification defaults
  • Updates generated JSON Schema artifacts (config.schema.json, docker_routes.schema.json, routes.schema.json) to match the new type definitions
  • Risk: notify is required on IdlewatcherConfig in api.ts; existing callers that do not supply it will fail type checks

Macroscope summarized ce9a5df.

Summary by CodeRabbit

  • New Features

    • Added configurable sleep and wake notifications for idle-watcher routes.
    • Notifications can be enabled or disabled and directed to selected notification providers, or all available providers.
    • Added support for idle notification settings across HTTP, file-server, and stream routes.
    • Added configuration validation for notification settings and provider destinations.
  • Documentation

    • Expanded route configuration guidance with notification options and a middleware example.

taljaards and others added 2 commits September 9, 2026 20:06
The committed schemas had drifted from their TypeScript sources; this is
a plain regeneration with no source changes.

Two user-visible effects:

- entrypoint.not_found was still typed as an array of RouteRule, but it
  became a rules string block. The config editor rejected the block form
  that config.example.yml documents.
- RuleDo missed the named option block for middleware actions in rules.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Mirrors the backend addition of opt-in sleep/wake notifications, sent
through the providers under providers.notification.

- config/config.ts gains defaults.idlewatcher.notify, the global opt-in.
- providers/idlewatcher.ts gains the notify event vocabulary and the
  three flat proxy.idle_notify* Docker labels.
- src/lib/api.ts and the JSON schemas are regenerated.

Without the schema update the config editor would reject the new keys,
since every generated schema sets additionalProperties: false.

Verified with ajv: defaults.idlewatcher.notify and the Docker labels
accept the documented shapes and reject unknown events and keys.

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

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown

@taljaards is attempting to deploy a commit to the GoDoxy Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 10d08e43-10a3-4bce-9757-ca7d086cfa2e

📥 Commits

Reviewing files that changed from the base of the PR and between f6a36c4 and ce9a5df.

📒 Files selected for processing (3)
  • src/types/godoxy/config.schema.json
  • src/types/godoxy/docker_routes.schema.json
  • src/types/godoxy/routes.schema.json

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The API and configuration types now support idlewatcher sleep/wake notifications. Route schemas define notification settings for HTTP, file-server, and stream routes, including provider targets and Docker labels.

Changes

Idlewatcher notifications

Layer / File(s) Summary
Notification contracts and defaults
src/lib/api.ts, src/types/godoxy/config/config.ts, src/types/godoxy/providers/idlewatcher.ts
Adds notification interfaces, default configuration, API fields, and Docker label properties for idlewatcher notifications.
Route schema wiring
src/types/godoxy/routes.schema.json, src/types/godoxy/docker_routes.schema.json
Adds notification definitions and route wiring for HTTP, file-server, and stream idlewatcher configurations. Updates RuleDo examples with a middleware RealIP example.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: yusing

Merge Risk: 🟡 Moderate · up to ce9a5

This adds opt-in idlewatcher notifications but also requires notification configuration in HTTP and stream route schemas. Existing routes may be rejected if defaults are not applied before validation, so compatibility handling should be confirmed before merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding sleep/wake notification configuration for idlewatcher.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit hops through config bright
And adds new signals for the night
Sleep and wake now softly chime
Providers answer right on time
Routes carry notes in tidy rows

Comment @coderabbitai help to get the list of available commands.

Follows the backend cut: the notify config is now just {enabled, to},
firing on sleep and wake. Removes the event vocabulary and the
proxy.idle_notify_events label, and regenerates api.ts and the schemas.

Verified with ajv: defaults.idlewatcher.notify and the Docker labels
accept the remaining shapes and now reject `events` along with any other
unknown key.

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

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Resolves the three JSON schema conflicts by regenerating them from the
merged TypeScript sources, rather than hand-merging minified JSON.

The result carries both sides: upstream's optional cidr_whitelist.allow,
the string-typed entrypoint not_found and the RuleDo middleware block,
plus this branch's idlewatcher notify config.

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