Skip to content

refactor(notify): extract NotificationBackend trait#621

Merged
Wirasm merged 2 commits intomainfrom
kild/trait-notify-config
Feb 28, 2026
Merged

refactor(notify): extract NotificationBackend trait#621
Wirasm merged 2 commits intomainfrom
kild/trait-notify-config

Conversation

@Wirasm
Copy link
Owner

@Wirasm Wirasm commented Feb 28, 2026

Summary

  • Adds NotificationBackend trait with name(), is_available(), send() following the existing TerminalBackend/ForgeBackend pattern
  • Extracts macOS (osascript) and Linux (notify-send) into separate backend structs with a registry for platform auto-detection
  • Adds NotifyError error type with KildError implementation
  • Adds 3 standard From trait implementations: AgentMode → OpenMode, kild_protocol::SessionStatus → core SessionStatus, &ProcessInfo → ProcessMetadata

Test plan

  • cargo fmt --check — 0 violations
  • cargo clippy --all -- -D warnings — 0 warnings
  • cargo test -p kild-protocol — 86 passed
  • cargo test -p kild-core — 972 passed
  • cargo build --all — clean build
  • Notification behavior unchanged — send_notification() still dispatches through the same platform code, just routed through the trait registry

Closes #435

…kends

Add trait-based extensibility for the notification subsystem, following
the existing TerminalBackend and ForgeBackend patterns:

- NotificationBackend trait with name/is_available/send interface
- MacOsNotificationBackend (osascript) and LinuxNotificationBackend (notify-send)
- Registry with platform-based auto-detection
- NotifyError type with KildError implementation

Also add standard From/TryFrom trait implementations:
- From<AgentMode> for OpenMode (kild-protocol)
- From<kild_protocol::SessionStatus> for core SessionStatus
- From<&ProcessInfo> for ProcessMetadata

Closes #435
- Remove dead NotifyError::IoError variant (YAGNI — no caller produces it)
- Remove redundant which::which check in LinuxNotificationBackend::send
  (is_available already gates dispatch; Command::new handles missing binary)
- Return bool from send_via_backend to distinguish sent vs skipped, fixing
  misleading send_completed log when no backend is available
- Remove premature lib.rs re-exports of NotificationBackend/NotifyError
  (no callers outside kild-core)
- Simplify registry detect() with find+map instead of verbose find_map
- Inline detect_backend() into send_via_backend (single caller)
- Add warn log on wildcard arm in From<SessionStatus> for unknown variants
- Add doc note on format_notification_message re "needs input" for Error
- Remove redundant test comments
@Wirasm Wirasm merged commit fac0826 into main Feb 28, 2026
6 checks passed
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.

Add trait-based extensibility for notification and config backends

1 participant