fix(remote): alert on Feishu delivery errors#1992
Conversation
📝 WalkthroughWalkthroughFeishu 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. ChangesFeishu delivery error propagation
Throttled remote notifications
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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 `@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
📒 Files selected for processing (8)
src/main/app/composition.tssrc/main/remote/channels/feishu/adapter.tssrc/main/remote/channels/feishu/feishuRuntime.tssrc/main/remote/index.tssrc/main/remote/ports.tstest/main/remote/feishuAdapter.test.tstest/main/remote/feishuRuntime.test.tstest/main/remote/remoteService.test.ts
| .then((notificationId) => { | ||
| if (notificationId) { | ||
| this.deliveryErrorNotifiedAt.set(channel, now) | ||
| } |
There was a problem hiding this comment.
🎯 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 withDate.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.
| .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.
Summary
Validation
Summary by CodeRabbit
New Features
Bug Fixes