fix: declare tab access permission#1
Conversation
- Replace activeTab with tabs so tab URLs are available for state checks - Rewrite popup and content async handlers without promise chains
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@coderabbitai Review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR refactors async error handling in the content script and popup UI to use shared async control flow while preserving response shapes, logging, toasts, and busy-state resets. The manifest permissions list also changes from ChangesAsync Refactor and Manifest Permission Update
Estimated code review effort: 2 (Simple) | ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/pages/popup/main.ts (1)
328-399: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting the repeated busy/try/catch/finally boilerplate.
All five click handlers share the same shape: set busy, await an action, render/toast on success, log+toast on failure, reset busy in
finally. A small helper (e.g.runWithBusy(button, action, { successToast, failToast, failLog })) would remove the duplication across Lines 328-399 and make future handlers easier to add consistently.♻️ Example helper
+async function runWithBusy( + button: HTMLButtonElement | null, + action: () => Promise<void>, + { failToast, failLog }: { failToast: string; failLog: string }, +) { + if (button) setElementBusy(button, true); + try { + await action(); + } catch (error: unknown) { + console.error(failLog, error); + showToast(failToast); + } finally { + if (button) setElementBusy(button, false); + } +}🤖 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/pages/popup/main.ts` around lines 328 - 399, The five click handlers in main.ts repeat the same busy/try/catch/finally pattern, so extract that flow into a shared helper to remove duplication. Create a reusable wrapper around the button busy state and async action (for example using the existing click handler blocks as callers) that handles setElementBusy, success/failure toasts, logging, and finally cleanup consistently. Then replace each inline async IIFE for the default downloader, switch, open picker, refresh, and clear actions with calls to that helper, keeping the existing render and toast behavior in the action-specific callbacks.
🤖 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.
Nitpick comments:
In `@src/pages/popup/main.ts`:
- Around line 328-399: The five click handlers in main.ts repeat the same
busy/try/catch/finally pattern, so extract that flow into a shared helper to
remove duplication. Create a reusable wrapper around the button busy state and
async action (for example using the existing click handler blocks as callers)
that handles setElementBusy, success/failure toasts, logging, and finally
cleanup consistently. Then replace each inline async IIFE for the default
downloader, switch, open picker, refresh, and clear actions with calls to that
helper, keeping the existing render and toast behavior in the action-specific
callbacks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1440efbb-60c7-46ce-a9c2-4014972ab865
📒 Files selected for processing (3)
src/app/content/index.tssrc/manifest.jsonsrc/pages/popup/main.ts
Summary
activeTabpermission withtabsso tab URLs are available for state checksVerification
npm run lintnpm testnpm run buildSummary by CodeRabbit