···11# Seams Refactoring Plan
2233+## Understanding the Project
44+55+Before starting any work, please review the documentation in the `history/` directory and `AGENTS.md`.
66+77+- **`AGENTS.md`**: The primary source of truth for system architecture, data flow, and development commands.
88+- **`history/STORAGE_FIRST_ARCHITECTURE.md`**: Details the "Storage-First" architecture used by the extension to ensure performance and offline capability.
99+1010+### Architecture Highlights
1111+- **Extension**: Uses WXT, `browser.storage.local` for state, and a background worker for syncing.
1212+- **Backend**: Go server with SQLite, indexing annotations from PDS via AT Protocol.
1313+- **Proxy**: A "via" style proxy for annotating pages without the extension installed.
1414+- **Landing**: A static landing page that displays a feed of global annotations.
1515+316## Phase 1: Core Data & Backend Standardization (Completed)
417- [x] **Standardize Annotation Type** (`server/internal/models/annotation.go`)
518 - Aligned Go `Annotation` struct with TypeScript definition and ATProto schema.
···2740 - [x] **Integrate into Landing** (`landing/landing.js`)
2841 - Import and use the web component, removing duplicate rendering code.
29423030-## Phase 3: OAuth Flow Modernization
3131-**Goal:** Improve authentication experience by removing popups.
3232-- [ ] **Switch to Same-Tab OAuth** (`packages/core/src/oauth/launchers.ts`)
3333- - Modify `WebOAuthLauncher` to use `window.location.assign`.
3434-- [ ] **Handle OAuth Redirects** (`entrypoints/via-client/oauth-callback.ts`)
3535- - Update callback to redirect back to origin using stored state.
3636-3737-## Phase 4: Content Script & Proxy Refactoring
4343+## Phase 3: Content Script & Proxy Refactoring
3844**Goal:** Clean up proxy client architecture and share logic.
3945- [ ] **Rename Proxy Script** (`packages/core/src/content/script.ts`)
4046 - Rename `ContentScript` to `ProxyContentScript`.
···4450 - Implement `notifySelectionChange` in proxy script.
4551- [ ] **Cleanup Event Handling**
4652 - Fix logic for detecting clicks inside/outside UI.
5353+5454+## Phase 4: OAuth Flow Modernization
5555+**Goal:** Improve authentication experience by removing popups.
5656+- [ ] **Switch to Same-Tab OAuth** (`packages/core/src/oauth/launchers.ts`)
5757+ - Modify `WebOAuthLauncher` to use `window.location.assign`.
5858+- [ ] **Handle OAuth Redirects** (`entrypoints/via-client/oauth-callback.ts`)
5959+ - Update callback to redirect back to origin using stored state.
47604861## Phase 5: Optimization & Cleanup
4962**Goal:** Performance improvements and dead code removal.