feat(hooks): add on_request_permission hook for external notifications#246
Conversation
Add new hook that fires when the agent requests user permission (e.g., for file edits). This enables external notification systems (like Ghostty OSC 9) to alert users when their attention is needed, even when they're not looking at the editor. Changes: - Add RequestPermissionData type to config_default.lua - Add on_request_permission to Hooks type and default config - Invoke hook in SessionManager:_build_handlers() with request, session_id, tab_page_id - Add unit tests in session_manager.test.lua Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
📝 WalkthroughWalkthroughThis PR introduces a new Sequence DiagramsequenceDiagram
participant Agent
participant SessionManager
participant InvokeHook as P.invoke_hook
participant Config as UserConfig
participant PermissionHandler as Handler
Agent->>SessionManager: Request tool execution
SessionManager->>InvokeHook: invoke_hook("on_request_permission", data)
InvokeHook->>Config: Lookup hooks.on_request_permission
alt Hook configured
Config->>PermissionHandler: Execute on_request_permission(data)
PermissionHandler->>PermissionHandler: Custom auth logic<br/>(derive label, notify user)
else Hook not set
InvokeHook->>InvokeHook: Return nil (no-op)
end
InvokeHook->>SessionManager: Return control
SessionManager->>SessionManager: Apply standard<br/>permission handling
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lua/agentic/session_manager.lua`:
- Around line 980-984: The hook payload uses self.session_id which can be stale;
update the P.invoke_hook call in the on_request_permission flow so the
session_id field comes from the incoming request (use request.sessionId) instead
of self.session_id, keeping tab_page_id as is; ensure you reference
request.sessionId in the payload when calling
P.invoke_hook("on_request_permission", {...}) to avoid misreporting after
session switches.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: b8e82fb1-0745-4a10-942b-858dcf92a9fa
📒 Files selected for processing (5)
README.mddoc/agentic.txtlua/agentic/config_default.lualua/agentic/session_manager.lualua/agentic/session_manager.test.lua
carlos-algms
left a comment
There was a problem hiding this comment.
@ro0gr Amazing. I don't know how it didn't come up earlier!
Add a new
on_request_permissionhook that fires when the agent requests user permission (e.g., for file edits).This complements the
on_response_completeto enable external notification systems (like Ghostty OSC 9) to alert users when their attention is needed, even when they're not looking at the editor.