# Tabvana

A Chrome extension for intelligent tab management — track, tag, search, and navigate your browsing history with semantic similarity.

## Features

### Tab Tracking
- Automatically tracks every tab you visit, with access timestamps and hotness scores
- Maintains an in-memory + IndexedDB store of all pages (normalized URLs, titles, visit history)
- Tracks tab relationships: which tabs opened which, and which tabs were open at the same time

### Tagging
- Add human tags to any page
- System tags: `#stash` (save for later), `#flag` (mark important), `#archive`
- Browse and filter pages by tag from the main UI
- Tag-based similarity: find pages with similar tag profiles

### Semantic Search
- Full-text search with prefix matching across all tracked pages (powered by MiniSearch)
- Semantic similarity search using ML embeddings (HuggingFace `all-MiniLM-L6-v2`, WASM, runs locally)
- Similarity computed in a background Web Worker — never blocks the UI

### Todos
- Attach todos to any page
- Due dates, priority levels, and completion tracking
- Pending todo count shown in the main UI tab bar

### Backup & Restore
- Automatic periodic backup to a user-selected local folder (File System Access API)
- Manual restore from a backup file
- Configurable backup interval

### Options
- Ignored URL patterns (skip tracking for matching pages)
- Custom URL normalization rules (strip/replace URL components)
- Similarity scaler settings (tune how cosine similarity is scored)
- Renormalize all stored pages against current rules

## Architecture

```
Service Worker (background/index.ts)
  ├── chromeTabsListeners.ts  → dispatches to Redux + dbSync
  ├── dbSync.ts               → writes to IndexedDB (Dexie)
  └── queueProcessor.ts       → processes async operation queue

Main UI Window (main/mainWithStore.tsx)
  └── Redux store (store/)
      ├── windowsSlice.ts     → Chrome windows/tabs state
      └── uiSlice.ts          → selection, search, similarity state

Offscreen Document (offscreen/offscreen.ts)
  └── embedding.ts            → HuggingFace Xenova/all-MiniLM-L6-v2 (WASM)
```

Async work (embedding generation, renormalization, title fetching, cleanup) is handled via a priority queue in IndexedDB processed by the service worker.

## Development

**Prerequisites:** Node.js 22+, Yarn

```bash
yarn install       # install dependencies
yarn dev           # Vite dev server with HMR
yarn build         # type-check + production build → dist/
yarn build:dev     # dev build with sourcemaps
yarn test          # Jest test suite
yarn lint          # ESLint + Prettier + stylelint
```

### Loading the extension in Chrome

1. Run `yarn build`
2. Go to `chrome://extensions`
3. Enable **Developer Mode**
4. Click **Load Unpacked** and select the `dist/` folder

**Global hotkey:** `Ctrl+Shift+A` (Mac: `Cmd+Shift+A`) opens the Tabvana window.

## Tech Stack

- **React** + **TypeScript** + **Redux Toolkit**
- **Dexie** (IndexedDB wrapper) with 18 schema versions
- **MiniSearch** for in-memory full-text search
- **HuggingFace Transformers.js** (`all-MiniLM-L6-v2`) for local WASM embeddings
- **MUI Joy** component library
- **Vite** + **@crxjs/vite-plugin** for MV3 extension bundling
- **Jest** + **ts-jest** + **fake-indexeddb** for testing

## License

MIT
