Skip to content

Feat: add hook system#9

Merged
davidborzek merged 7 commits intomainfrom
feat/hooks
Mar 8, 2026
Merged

Feat: add hook system#9
davidborzek merged 7 commits intomainfrom
feat/hooks

Conversation

@davidborzek
Copy link
Copy Markdown
Owner

@davidborzek davidborzek commented Mar 8, 2026

Summary

  • Add configurable hooks that run shell commands on profile and call events
  • Hooks are defined in ringo.toml as [[hooks]] entries with event and command fields
  • Commands run in background threads (non-blocking) with environment variables RINGO_EVENT, RINGO_PROFILE, RINGO_PROFILE_JSON, and RINGO_EVENT_DATA (JSON)
  • Supported events: profile_loaded, call_incoming, call_outgoing, call_ended
  • Add unified logging module (src/log.rs) writing to /tmp/ringo-<name>.log — replaces ad-hoc /tmp/ringo-hooks.log
  • Surface previously silent errors: TCP disconnects, config parse failures, baresip lifecycle, call/dial history writes, dropped commands

Hook events

Event Trigger Event data
profile_loaded After profile is loaded and baresip is spawned
call_incoming Incoming call received call_id, number, display_name
call_outgoing Outgoing call initiated call_id, number
call_ended Call closed/ended call_id, number, direction, duration_secs, reason, error

Test plan

  • All 88 existing tests pass
  • Manually test hooks with all four events
  • Verify RINGO_EVENT_DATA JSON is correct for each event
  • Verify hooks don't block the TUI
  • Verify config parse errors appear in /tmp/ringo-<name>.log
  • Kill baresip → verify TCP reader error logged

🤖 Generated with Claude Code

davidborzek and others added 7 commits March 8, 2026 15:22
Run shell commands on profile events (e.g. profile_loaded).
Hooks are configured in ringo.toml as [[hooks]] entries.
Commands run in background threads with stdout/stderr logged
to /tmp/ringo-hooks.log.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduces src/log.rs with OnceLock<Mutex<File>>, writing to
/tmp/ringo-{profile}.log. Replaces ad-hoc logging in hooks.rs and
surfaces previously silent errors across TCP, config parsing, baresip
lifecycle, call history, dial history, notify-send, and phone commands.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Hooks now fire on incoming and outgoing calls with event data
(call_id, number, display_name) passed as RINGO_EVENT_DATA JSON
and individual RINGO_<KEY> env vars.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fires when a call closes with event data: call_id, number, direction,
duration_secs, reason, and error flag.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…NT_DATA JSON

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@davidborzek davidborzek marked this pull request as ready for review March 8, 2026 15:06
@davidborzek davidborzek merged commit 4509516 into main Mar 8, 2026
1 check passed
@davidborzek davidborzek deleted the feat/hooks branch March 8, 2026 15:16
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