-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: broken capture list failure mechanism #878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request refactors notification handling in the BrowserWindow component to implement a deferred notification workflow. Instead of immediately notifying users when list field extraction operations occur, notifications are now queued in a Changes
Sequence DiagramsequenceDiagram
autonumber
participant User
participant BrowserWindow
participant NotificationSystem
rect rgb(200, 220, 255)
note over BrowserWindow: Old Flow: Immediate Notifications
User->>BrowserWindow: Select list field
BrowserWindow->>NotificationSystem: notify(type, message)
BrowserWindow->>NotificationSystem: notify(type, message)
BrowserWindow->>User: Multiple notifications
end
rect rgb(220, 240, 220)
note over BrowserWindow: New Flow: Deferred Notifications
User->>BrowserWindow: Select list field
BrowserWindow->>BrowserWindow: Set pendingNotification
BrowserWindow->>BrowserWindow: Execute addListStep
BrowserWindow->>BrowserWindow: Flush pendingNotification
BrowserWindow->>NotificationSystem: notify(stored type, message)
BrowserWindow->>User: Single consolidated notification
end
rect rgb(255, 230, 220)
note over BrowserWindow: Failure Path: State Cleanup
User->>BrowserWindow: Extract fails
BrowserWindow->>BrowserWindow: Reset state fields
BrowserWindow->>NotificationSystem: notify(error type, message)
BrowserWindow->>User: Error notification
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/components/browser/BrowserWindow.tsx (1)
1209-1223: RemovependingNotificationfrom the dependency array.Including
pendingNotificationin the dependency array causes the effect to re-run unnecessarily when the notification is flushed (lines 1180, 1191). While thecachedListSelector !== listSelectorguard at line 1134 prevents harmful re-processing, this still triggers unnecessary effect invocations and violates React Hook best practices.The effect primarily responds to
listSelectorchanges, andpendingNotificationis only consumed (not observed for changes), so it should be excluded from the dependencies.Apply this diff:
}, [ isDOMMode, listSelector, socket, getList, currentSnapshot, cachedListSelector, - pendingNotification, notify, createFieldsFromChildSelectors, currentListId, currentListActionId, paginationSelector, addListStep ]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/browser/BrowserWindow.tsx(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/components/browser/BrowserWindow.tsx (1)
src/helpers/clientSelectorGenerator.ts (1)
setListSelector(142-144)
🔇 Additional comments (4)
src/components/browser/BrowserWindow.tsx (4)
180-184: LGTM! Well-structured notification state.The
pendingNotificationstate properly encapsulates the notification data (type, message, count) needed for deferred notifications.
1178-1181: Verify error handling foraddListStep.The success notification is flushed immediately after
addListStepcompletes (lines 1168-1176). IfaddListStepfails silently or throws an error that's caught elsewhere, the success notification would still be displayed, potentially misleading the user.Consider wrapping
addListStepin a try-catch block to ensure the success notification is only shown when the operation genuinely succeeds:+ try { addListStep( listSelector, autoFields, currentListId || Date.now(), currentListActionId || `list-${crypto.randomUUID()}`, { type: "", selector: paginationSelector }, undefined, false ); if (pendingNotification) { notify(pendingNotification.type, pendingNotification.message); setPendingNotification(null); } + } catch (error) { + console.error("Failed to add list step:", error); + setPendingNotification(null); + notify("error", "Failed to process the selected list. Please try again."); + }
1182-1197: Excellent state cleanup and error handling!The failure path correctly:
- Resets all related state fields to ensure clean state
- Clears the pending notification without sending it (since an error occurred)
- Provides a clear, actionable error message to the user
This properly addresses the PR objective of notifying users when the selected list is invalid.
1728-1738: LGTM! Proper implementation of deferred notification.Correctly queues the success notification instead of showing it immediately. The notification will be flushed after field extraction completes successfully (lines 1178-1181), or suppressed if extraction fails (line 1191). This ensures users only see success messages when the operation genuinely succeeds.
What this PR does?
Checks if the selected list is valid and notifies the user to reselect.
Fixes: #877
2025-11-06.23-20-10.mp4
Summary by CodeRabbit