Skip to content

Add agent hooks for chat gui#1303

Merged
Kitenite merged 2 commits into
mainfrom
kitenite/claude-sdk-hooks-support
Feb 8, 2026
Merged

Add agent hooks for chat gui#1303
Kitenite merged 2 commits into
mainfrom
kitenite/claude-sdk-hooks-support

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 8, 2026

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

Release Notes

  • New Features
    • Improved AI chat session management with pane and tab context tracking for better multi-pane workspace organization
    • Introduced notification webhooks for AI chat events, enabling real-time event notifications to local endpoints

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 8, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR threads pane and tab context identifiers through the AI chat session and agent infrastructure, extending session start/restore operations with paneId and tabId parameters. A new notification feature is introduced to emit local webhook callbacks with session context metadata to a designated port.

Changes

Cohort / File(s) Summary
TRPC Router & Session Manager
apps/desktop/src/lib/trpc/routers/ai-chat/index.ts, apps/desktop/src/lib/trpc/routers/ai-chat/utils/session-manager/session-manager.ts
Added optional paneId and tabId input parameters to startSession and restoreSession mutations; propagated through to underlying session manager calls.
Agent Provider Infrastructure
apps/desktop/src/lib/trpc/routers/ai-chat/utils/agent-provider/claude-sdk-provider.ts, apps/desktop/src/lib/trpc/routers/ai-chat/utils/agent-provider/types.ts
Extended getAgentRegistration method signature with optional paneId, tabId, workspaceId parameters; added notification object to body template containing port, identifiers, and environment indicator.
UI Components
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/ChatPane/ChatInterface/ChatInterface.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/ChatPane/ChatPane.tsx
Added paneId and tabId props to ChatInterface; threaded them through session management calls and effect dependencies.
Agent Streaming & Notifications
apps/streams/src/claude-agent.ts
Introduced notificationSchema and NotificationContext type; added buildNotificationHooks function to construct webhook matchers for user prompt and stop events; integrated conditional hook generation based on notification presence.
Import Reorganization
apps/streams/src/sdk-to-ai-chunks.ts
Relocated type-only import for StreamChunk to appear after runtime imports.

Sequence Diagram

sequenceDiagram
    participant UI as ChatInterface Component
    participant Router as TRPC Router
    participant SessionMgr as SessionManager
    participant AgentProvider as ClaudeSdkProvider
    participant Agent as Claude Agent
    participant Webhook as Notification Webhook

    UI->>Router: startSession({sessionId, paneId, tabId, ...})
    Router->>SessionMgr: startSession({sessionId, paneId, tabId, ...})
    SessionMgr->>AgentProvider: getAgentRegistration({sessionId, paneId, tabId, ...})
    AgentProvider->>Agent: Send request with notification({port, paneId, tabId, env})
    Agent->>Agent: buildNotificationHooks({notification})
    Agent->>Webhook: POST /hook/complete (UserPromptSubmit event)
    Webhook-->>Agent: Acknowledgement
    Agent-->>AgentProvider: AgentRegistration + session context
    AgentProvider-->>SessionMgr: Registration complete
    SessionMgr-->>Router: Session started
    Router-->>UI: Session ready
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 With paneId and tabId sewn tight,
The chat skips from pane to tab's delight,
Notifications ping through the wire with cheer,
Context flows perfect—oh crystal clear! 🎉
A hoppy agent wears session like a crown,
The fluffiest threading in all of the town! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kitenite/claude-sdk-hooks-support

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

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

@Kitenite Kitenite merged commit 46ecc4d into main Feb 8, 2026
4 of 5 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 8, 2026

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) View Branch
Fly.io Electric (Fly.io) View App
Vercel API (Vercel) Open Preview
Vercel Web (Vercel) Open Preview
Vercel Marketing (Vercel) Open Preview
Vercel Admin (Vercel) Open Preview
Vercel Docs (Vercel) Open Preview

Preview updates automatically with new commits

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