Skip to content

fix(remote): alert on Feishu delivery errors#1992

Merged
zerob13 merged 1 commit into
devfrom
feat/feishu-delivery-alerts
Jul 18, 2026
Merged

fix(remote): alert on Feishu delivery errors#1992
zerob13 merged 1 commit into
devfrom
feat/feishu-delivery-alerts

Conversation

@zhangmo8

@zhangmo8 zhangmo8 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • surface Feishu inbound and reply-delivery failures in runtime status
  • send a throttled desktop alert when the fallback error reply cannot be delivered
  • avoid exposing upstream error details in runtime status or notification content
  • retry notification attempts when alerts are disabled or notification delivery fails

Validation

  • pnpm run format
  • pnpm run i18n
  • pnpm run lint
  • pnpm run typecheck
  • pnpm exec vitest --config vitest.config.ts --run test/main/remote/feishuRuntime.test.ts test/main/remote/feishuAdapter.test.ts test/main/remote/remoteService.test.ts test/main/desktop/notification.test.ts

Summary by CodeRabbit

  • New Features

    • Added desktop notifications for Feishu message delivery failures.
    • Delivery error notifications are rate-limited to prevent repeated alerts.
    • Notifications can be disabled when needed.
  • Bug Fixes

    • Feishu connection status now records inbound message and reply delivery failures.
    • Inbound handling errors no longer silently disappear, while the service remains available.
    • Delivery error alerts are retried after failed notification attempts.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Feishu runtime failures now update status snapshots and expose delivery-error callbacks. The remote service forwards those errors to a desktop notification port with per-channel throttling and retry handling.

Changes

Feishu delivery error propagation

Layer / File(s) Summary
Runtime error status and callback handling
src/main/remote/channels/feishu/feishuRuntime.ts, src/main/remote/channels/feishu/adapter.ts, test/main/remote/feishuRuntime.test.ts, test/main/remote/feishuAdapter.test.ts
Inbound failures and reply-delivery failures update runtime status; delivery errors are forwarded through the adapter callback and covered by tests.

Throttled remote notifications

Layer / File(s) Summary
Notification contract and composition wiring
src/main/remote/ports.ts, src/main/app/composition.ts
A remote notification port is defined and exposed through the desktop control surface.
Per-channel delivery-error notifications
src/main/remote/index.ts, test/main/remote/remoteService.test.ts
RemoteService throttles notifications per channel, prevents concurrent duplicates, records successful notification timestamps, and retries failed attempts.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Feishu
  participant FeishuRuntime
  participant FeishuAdapter
  participant RemoteService
  participant DesktopNotifications
  Feishu->>FeishuRuntime: Deliver inbound message
  FeishuRuntime->>FeishuRuntime: Process message and send reply
  FeishuRuntime->>FeishuAdapter: Report reply-delivery error
  FeishuAdapter->>RemoteService: Forward channel error
  RemoteService->>RemoteService: Apply throttle and in-flight checks
  RemoteService->>DesktopNotifications: Show notification
Loading

Suggested reviewers: zerob13

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: alerting on Feishu delivery errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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/feishu-delivery-alerts

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 `@src/main/remote/index.ts`:
- Around line 2593-2596: Update the success handler in the notification delivery
promise in src/main/remote/index.ts (lines 2593-2596) to store the current
Date.now() value in deliveryErrorNotifiedAt when notification delivery succeeds,
rather than the earlier now timestamp. In test/main/remote/remoteService.test.ts
(lines 222-240), await in-flight completion before issuing the second call so
the test validates time-based throttling after delivery completes.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 10ac8a9e-b829-475d-99a5-b67259d5158c

📥 Commits

Reviewing files that changed from the base of the PR and between e84428b and d58922c.

📒 Files selected for processing (8)
  • src/main/app/composition.ts
  • src/main/remote/channels/feishu/adapter.ts
  • src/main/remote/channels/feishu/feishuRuntime.ts
  • src/main/remote/index.ts
  • src/main/remote/ports.ts
  • test/main/remote/feishuAdapter.test.ts
  • test/main/remote/feishuRuntime.test.ts
  • test/main/remote/remoteService.test.ts

Comment thread src/main/remote/index.ts
Comment on lines +2593 to +2596
.then((notificationId) => {
if (notificationId) {
this.deliveryErrorNotifiedAt.set(channel, now)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Record the throttle timestamp when notification delivery succeeds.

A notification lasting over one minute stores an already-expired now, allowing another alert immediately after completion.

  • src/main/remote/index.ts#L2593-L2596: set the value with Date.now() inside the success handler.
  • test/main/remote/remoteService.test.ts#L222-L240: wait for in-flight completion before the second call so the test exercises time throttling rather than only in-flight deduplication.
Proposed fix
       .then((notificationId) => {
         if (notificationId) {
-          this.deliveryErrorNotifiedAt.set(channel, now)
+          this.deliveryErrorNotifiedAt.set(channel, Date.now())
         }
       })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.then((notificationId) => {
if (notificationId) {
this.deliveryErrorNotifiedAt.set(channel, now)
}
.then((notificationId) => {
if (notificationId) {
this.deliveryErrorNotifiedAt.set(channel, Date.now())
}
})
📍 Affects 2 files
  • src/main/remote/index.ts#L2593-L2596 (this comment)
  • test/main/remote/remoteService.test.ts#L222-L240
🤖 Prompt for 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.

In `@src/main/remote/index.ts` around lines 2593 - 2596, Update the success
handler in the notification delivery promise in src/main/remote/index.ts (lines
2593-2596) to store the current Date.now() value in deliveryErrorNotifiedAt when
notification delivery succeeds, rather than the earlier now timestamp. In
test/main/remote/remoteService.test.ts (lines 222-240), await in-flight
completion before issuing the second call so the test validates time-based
throttling after delivery completes.

@zerob13
zerob13 merged commit 7223f45 into dev Jul 18, 2026
4 checks passed
@zhangmo8
zhangmo8 deleted the feat/feishu-delivery-alerts branch July 18, 2026 01:59
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.

2 participants