A browser extension + Electron app that detects tab thrashing and helps you focus by hiding distracting tabs using AI.
browser-plugin/ # WXT browser extension (Chrome/Firefox)
└─ background.ts # Tracks tab switches, sends events to Electron
└─ popup/ # Focus Mode UI button
electron-app/ # Electron desktop app
└─ src/lib/db.ts # SQLite storage for tab events
└─ src/lib/event-server.ts # HTTP server on localhost:3456
└─ src/lib/thrash-detector.ts # Sliding window thrash detection
└─ src/lib/focus-advisor.ts # Gemini via OpenRouter for focus suggestions
- Node.js 18+
- npm
- An OpenRouter API key
- Clone the repo and copy the env file:
cp .env.example .env- Add your OpenRouter API key to
.env:
OPENROUTER_API_KEY=sk-or-your-key-here
- Install dependencies in both projects:
cd electron-app && npm install
cd ../browser-plugin && npm installYou need both the Electron app and browser plugin running.
cd electron-app
npm startThis starts:
- The desktop window
- A local HTTP server on
http://127.0.0.1:3456 - SQLite database at
~/Library/Application Support/my-app/tab-events.db
cd browser-plugin
npm run devThis opens a Chrome instance with the extension loaded. The extension will:
- Track every tab switch and send events to the Electron app
- Detect thrashing (5+ switches across 3+ tabs in 30 seconds)
- Provide a Focus Mode button in the popup to clean up distracting tabs via AI
- Tab tracking: Happens automatically in the background
- Thrash detection: Watch the Electron terminal for
THRASH DETECTEDalerts - Focus Mode: Click the extension icon → "Activate Focus Mode" → review AI suggestions → close selected tabs