Skip to content

fix: declare tab access permission#1

Merged
Chumor merged 2 commits into
mainfrom
fix/tab-access-permission
Jul 4, 2026
Merged

fix: declare tab access permission#1
Chumor merged 2 commits into
mainfrom
fix/tab-access-permission

Conversation

@Chumor

@Chumor Chumor commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace the unused activeTab permission with tabs so tab URLs are available for state checks
  • rewrite popup and content async handlers without promise chains

Verification

  • npm run lint
  • npm test
  • npm run build

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of popup actions and site toggles with more consistent error handling and feedback.
    • Loading/busy indicators now reset more predictably after actions succeed or fail.
    • Refresh state behavior is more resilient to storage-related updates.
  • Permissions
    • Updated extension permissions to provide broader tab access for improved functionality.

- Replace activeTab with tabs so tab URLs are available for state checks
- Rewrite popup and content async handlers without promise chains
@chatgpt-codex-connector

This comment was marked as off-topic.

@Chumor

Chumor commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai Review

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 617f963c-25d5-480b-9a68-07031e9c544f

📥 Commits

Reviewing files that changed from the base of the PR and between 3523537 and c4d3142.

📒 Files selected for processing (1)
  • src/pages/popup/main.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/popup/main.ts

📝 Walkthrough

Walkthrough

This 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 activeTab to tabs.

Changes

Async Refactor and Manifest Permission Update

Layer / File(s) Summary
Manifest permission swap
src/manifest.json
The permissions array changes from ["storage", "activeTab"] to ["storage", "tabs"].
Content script async handlers
src/app/content/index.ts
The toggle-current-site message handler and storage-change refresh logic are converted from .then/.catch chains to async IIFEs with try/catch, preserving response shapes and error logging.
Popup event handler async refactor
src/pages/popup/main.ts
A shared popup async helper is added, and multiple click handlers are updated to use it for consistent busy-state handling, error logging, and failure toasts while keeping success behavior unchanged.

Estimated code review effort: 2 (Simple) | ~12 minutes

Poem

Hop, hop, the async paths now flow,
with tidy tries and catches below.
Tabs replace the active door,
the popup paces less and more,
and rabbit logs stay neat and low. 🐇

🚥 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 accurately reflects the main change: replacing activeTab with tabs to declare tab access permission.
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 fix/tab-access-permission

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/pages/popup/main.ts (1)

328-399: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider 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

📥 Commits

Reviewing files that changed from the base of the PR and between 83eb2a7 and 3523537.

📒 Files selected for processing (3)
  • src/app/content/index.ts
  • src/manifest.json
  • src/pages/popup/main.ts

@Chumor
Chumor merged commit c0a3ff7 into main Jul 4, 2026
2 checks passed
@Chumor
Chumor deleted the fix/tab-access-permission branch July 4, 2026 12:07
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