Skip to content

Feat/weixin#13

Merged
cnjack merged 4 commits intomainfrom
feat/weixin
Apr 16, 2026
Merged

Feat/weixin#13
cnjack merged 4 commits intomainfrom
feat/weixin

Conversation

@cnjack
Copy link
Copy Markdown
Owner

@cnjack cnjack commented Apr 16, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • WeChat channel integration with push notifications for approvals and task completions
    • /channel command in TUI to manage WeChat channel (login, logout, enable, disable)
    • Channels settings panel in web interface with QR code scanning support
  • Documentation

    • Channel configuration reference and setup guide
    • Channel capabilities documentation
    • Web API endpoints for channel operations

cnjack added 4 commits April 17, 2026 01:55
- Updated SettingsDialog.vue to include a new "Channels" tab for WeChat integration.
- Implemented channel status checks, login, logout, enable, and disable functionalities.
- Added QR code generation for WeChat login using the qrcode library.
- Enhanced API with new endpoints for channel management.
- Introduced UI elements for displaying channel status and actions.
@cnjack cnjack merged commit db6da3b into main Apr 16, 2026
1 check was pending
@cnjack cnjack deleted the feat/weixin branch April 16, 2026 18:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 596fd3ec-82f7-46f2-b504-240b62c4d757

📥 Commits

Reviewing files that changed from the base of the PR and between 99d30e3 and 405b481.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (37)
  • docs/configuration.md
  • docs/overview.md
  • docs/overview/channels.md
  • docs/web-interface.md
  • go.mod
  • internal-docs/external/weixin.spec.md
  • internal/channel/channel.go
  • internal/channel/channel_test.go
  • internal/channel/messages.go
  • internal/command/channel.go
  • internal/command/interactive.go
  • internal/command/web.go
  • internal/config/config.go
  • internal/handler/handler.go
  • internal/handler/notifying.go
  • internal/handler/notifying_test.go
  • internal/handler/web.go
  • internal/pkg/weixin/api.go
  • internal/pkg/weixin/client.go
  • internal/tui/channel_panel.go
  • internal/tui/input_views.go
  • internal/tui/messages.go
  • internal/tui/tui.go
  • internal/web/channel.go
  • internal/web/server.go
  • script/poc/weixin_poc.go
  • web/package.json
  • web/src/App.vue
  • web/src/components/ChatInput.vue
  • web/src/components/ChatMessage.vue
  • web/src/components/SettingsDialog.vue
  • web/src/composables/api.ts
  • web/src/composables/sse.ts
  • web/src/composables/ws.ts
  • web/src/stores/chat.ts
  • web/src/types/api.ts
  • weixin_poc

📝 Walkthrough

Walkthrough

This pull request introduces a complete WeChat messaging integration for the agent system. Users can connect via WeChat to receive notifications when agent approvals are needed or tasks complete, and can send prompts back to the agent. The feature includes TUI/web setup flows, credential persistence, delay-based approval notifications, and message formatting.

Changes

Cohort / File(s) Summary
Documentation & Configuration
docs/configuration.md, docs/overview.md, docs/overview/channels.md, docs/web-interface.md
Added new "Channels" capability documentation and channel.web_enabled configuration for WeChat integration with setup instructions for TUI/web interfaces.
Channel Abstraction
internal/channel/channel.go, internal/channel/channel_test.go, internal/channel/messages.go
Introduced Channel interface with lifecycle methods (Login, Logout, Enable, Disable, SendText), state management, and message formatting helpers for time-aware greetings, approval delays, and task completion notifications.
WeChat API Client
internal/pkg/weixin/api.go, internal/pkg/weixin/client.go
Implemented iLink Bot HTTP client with QR code login flow, long-poll message retrieval, credential persistence (at ~/.jcode/channel/wechat.json), and automatic session management with retry/backoff behavior.
TUI Integration
internal/tui/channel_panel.go, internal/tui/input_views.go, internal/tui/messages.go, internal/tui/tui.go, internal/command/channel.go, internal/command/interactive.go
Added /channel command, interactive channel panel with QR code rendering and action selection, WeChat client initialization/auto-enable, welcome/goodbye messages, and approval/completion event forwarding.
Web Integration
internal/web/channel.go, internal/web/server.go
Added HTTP endpoints (GET /api/channel, POST /api/channel/login, logout, enable, disable) for channel status and lifecycle management, auto-enable on startup when configured.
Event Handler & Notifications
internal/handler/handler.go, internal/handler/notifying.go, internal/handler/notifying_test.go, internal/handler/web.go
Introduced NotifyingHandler wrapper that schedules delayed approval notifications via callback and captures agent completion summaries (600 char limit), along with ToolCallID field on ApprovalRequest for tracking specific approvals.
Configuration
internal/config/config.go
Added ChannelConfig struct with WebEnabled boolean flag for configuring web-mode channel auto-enable.
Web Frontend
web/src/App.vue, web/src/components/ChatInput.vue, web/src/components/ChatMessage.vue, web/src/components/SettingsDialog.vue, web/src/composables/api.ts, web/src/composables/sse.ts, web/src/composables/ws.ts, web/src/stores/chat.ts, web/src/types/api.ts, web/package.json
Added Channels settings tab with WeChat QR login UI, channel toggle button in chat, inbound message display with source field, and corresponding Pinia store actions/state; extended API client and SSE/WebSocket handlers for channel events; added qrcode library.
Dependencies & Utilities
go.mod, internal-docs/external/weixin.spec.md, script/poc/weixin_poc.go
Updated Go dependencies with QR/terminal libraries; added iLink Bot API specification document; included standalone proof-of-concept WeChat bot implementation.

Sequence Diagram(s)

sequenceDiagram
    participant User as User (WeChat)
    participant TUI/Web as TUI/Web Interface
    participant Agent as Agent
    participant WeChatClient as WeChat Client
    participant Handler as NotifyingHandler
    participant iLink as iLink Bot API

    User->>TUI/Web: Scan QR / Click Connect
    TUI/Web->>WeChatClient: Login()
    WeChatClient->>iLink: FetchQRCode()
    iLink-->>WeChatClient: QR Content & Session Key
    WeChatClient-->>TUI/Web: LoginSession with QR
    TUI/Web->>User: Display QR Code

    User->>iLink: Scan QR
    iLink->>WeChatClient: (poll) PollLoginUntilDone()
    iLink-->>WeChatClient: Login Confirmed
    WeChatClient->>WeChatClient: Save Credentials
    WeChatClient-->>TUI/Web: Login Success

    TUI/Web->>WeChatClient: Enable()
    WeChatClient->>iLink: GetUpdates (long-poll)
    WeChatClient-->>TUI/Web: Enable Success
    TUI/Web->>User: Welcome Message

    Agent->>Handler: RequestApproval(toolName, args)
    Handler->>Handler: Schedule Notification (after delay)
    
    par Approval Wait & Notification
        Handler->>Handler: Wait for approval response
        Handler->>Handler: Delay elapsed, approval still pending
        Handler->>WeChatClient: SendText(ApprovalMessage)
        WeChatClient->>iLink: SendMessage
        iLink-->>WeChatClient: Ack
        WeChatClient-->>User: Approval notification
    and User Responds
        User->>iLink: Scan QR or send text prompt
        iLink-->>WeChatClient: GetUpdates returns message
        WeChatClient->>TUI/Web: onMessage callback
        TUI/Web->>Agent: Submit as user prompt
    end

    Agent->>Handler: OnAgentDone(summary, err)
    Handler->>Handler: Capture summary (last 600 chars)
    Handler->>WeChatClient: SendText(DoneMessage)
    WeChatClient->>iLink: SendMessage
    iLink-->>WeChatClient: Ack
    WeChatClient-->>User: Task completion message
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly Related PRs

Poem

🐰 A WeChat whisper across the digital streams,
When approvals call and tasks complete their dreams,
QR codes twinkle, credentials tucked away,
The agent now chats from dawn until day!
🎉✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/weixin

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.

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