Skip to content

feat(rules): toggle rules with keyboard shortcuts - #571

Merged
sebastienfontaine merged 1 commit into
masterfrom
feat/rule-toggle-shortcuts
Oct 14, 2026
Merged

sebastienfontaine merged 1 commit into
masterfrom
feat/rule-toggle-shortcuts

Conversation

@sebastienfontaine

Copy link
Copy Markdown
Contributor

Closes #557.

Use case

Some rules are "session" rules (e.g. News - {title} on any site, read by ActivityWatch). Turning them on and off meant going to the options page each time.

Feature

  • 10 commands toggle-rule-1 … toggle-rule-10 in manifest.json, without default keys: Chrome only allows 4 suggested keys, and this avoids clashing with users' shortcuts. Users assign keys in chrome://extensions/shortcuts.
  • Rule form → Advanced → Keyboard shortcut: None or Shortcut 1 … Shortcut 10, each showing the key already assigned (or "no key set"), plus a Set keys link that opens chrome://extensions/shortcuts.
  • Several rules can share a shortcut and are toggled as a group: if any of them is enabled they are all disabled, otherwise all enabled.
  • Feedback: ON / OFF badge on the toolbar icon for 2 s (– when no rule uses that shortcut).
  • Applied immediately, no reload: open web pages re-apply their rules (new reapplyRules message). When no rule applies anymore, the page's own title is restored and the title observer is stopped (the favicon comes back on the next load). An open options page reloads its list.
  • The rules table shows a ⌨ N badge next to rules that have a shortcut.

Implementation

  • RuleShortcutService (background): command → slot, toggle, badge, propagation.
  • RuleApplicationService.reset() (content): disconnect observers, restore the original title.
  • Rule.shortcut?: number | null (optional, existing rules unaffected); RULE_SHORTCUT_SLOTS in types.ts.

Tests

  • Unit: command parsing (and a check that manifest.json declares exactly slots 1–10), group toggle (any enabled → all off, else all on, missing is_enabled, unused slot), badge, propagation (tabs without content script, no options page open), reset() (title restored, disabled rule not reapplied on the next title change, switching rules starts from the original title).
  • Real browser (Playwright, built extension): form lists None + 10 shortcuts, table shows ⌨ 1, rule applied on load, disabled → original title restored without reload, re-enabled → applied again.
  • Not automatable: pressing an actual extension shortcut (handled by Chrome itself). Worth a manual check: assign a key to "Toggle the rules assigned to shortcut 1", press it on a page.
  • 241 tests, ESLint, Prettier, vue-tsc and build pass.

Declares 10 toggle-rule-N commands without default keys (assigned in
chrome://extensions/shortcuts). A rule can be assigned to a shortcut;
pressing it toggles all rules of that shortcut as one group, shows
ON/OFF on the toolbar icon, and re-applies rules in open tabs (restoring
the page title when no rule applies anymore) and in the options page.
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 58.53% 679 / 1160
🔵 Statements 58.88% 716 / 1216
🔵 Functions 65.07% 136 / 209
🔵 Branches 53.28% 333 / 625
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
manifest.json 100% 100% 100% 100%
src/background/RuleShortcutService.ts 96.77% 95% 100% 100% 30
src/common/types.ts 100% 100% 100% 100%
src/content/RuleApplicationService.ts 50% 39.62% 40% 51.31% 27, 31, 35, 45, 49, 54, 59-61, 115, 121-127, 141-190
Generated in workflow #477 for commit f2f193c by the Vitest Coverage Report Action

@github-actions

Copy link
Copy Markdown

📦 Extension Build Ready!

Version: 1.1.6

📥 Download Extension (tabee.zip)

Installation

  1. Download and extract the zip file
  2. Open Chrome → chrome://extensions/
  3. Enable "Developer mode" (top right)
  4. Click "Load unpacked" → Select the extracted folder

Status

  • ✅ All tests passed
  • ✅ Build successful
  • ✅ Ready for testing

🤖 Auto-generated by GitHub Actions

@sebastienfontaine
sebastienfontaine merged commit 5c2da7d into master Oct 14, 2026
7 checks passed
@sebastienfontaine
sebastienfontaine deleted the feat/rule-toggle-shortcuts branch October 14, 2026 21:59
@sebastienfontaine sebastienfontaine mentioned this pull request Oct 14, 2026
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.

Dynamically switchable rules

1 participant