refactor(notify): extract NotificationBackend trait#621
Merged
Conversation
…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
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
NotificationBackendtrait withname(),is_available(),send()following the existingTerminalBackend/ForgeBackendpatternNotifyErrorerror type withKildErrorimplementationFromtrait implementations:AgentMode → OpenMode,kild_protocol::SessionStatus → core SessionStatus,&ProcessInfo → ProcessMetadataTest plan
cargo fmt --check— 0 violationscargo clippy --all -- -D warnings— 0 warningscargo test -p kild-protocol— 86 passedcargo test -p kild-core— 972 passedcargo build --all— clean buildsend_notification()still dispatches through the same platform code, just routed through the trait registryCloses #435