From 5157428e747c17bf9d495356766daaf8faa75de3 Mon Sep 17 00:00:00 2001 From: MacBook Date: Mon, 4 May 2026 05:41:43 +0200 Subject: [PATCH] docs: comprehensive repository polish + step-by-step user guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Documentation Rewrites: - AI_INIT.md: fix duplicate section numbers, add file responsibility map, fix stale manual mirror instruction, add room ID constraint - PRIVACY.md: add TL;DR statement, data retention table, explicit justification, self-hosted instance disclaimer - CONTRIBUTING.md: add local testing guide, version warning, room ID constraint, bug report requirements - shared/README.md: complete event table (all 15 events), fix stale manifest.json reference - docs/SYNC_GUIDE.md: Chrome→Browser, add README.md to sync list, drop stale RC5 reference - server/README.md: sync env defaults with .env.example (1000/50) New Documentation: - docs/HOW_IT_WORKS.md: 10-step walkthrough covering room creation, invitation bridge flow, synchronized playback, force sync protocol, heartbeat system, and episode auto-sync. Includes exact data payloads. Infrastructure Cleanup: - docker-compose.yml: remove deprecated version key - .dockerignore: remove dead .bat/.sh patterns - README.md: add self-hosting extension config tip, link HOW_IT_WORKS --- .dockerignore | 2 - AI_INIT.md | 42 ++++++--- CONTRIBUTING.md | 31 ++++++- PRIVACY.md | 20 +++- README.md | 3 + docker-compose.yml | 1 - docs/HOW_IT_WORKS.md | 213 +++++++++++++++++++++++++++++++++++++++++++ docs/README.md | 1 + docs/SYNC_GUIDE.md | 11 ++- server/README.md | 4 +- shared/README.md | 34 ++++--- 11 files changed, 320 insertions(+), 42 deletions(-) create mode 100644 docs/HOW_IT_WORKS.md diff --git a/.dockerignore b/.dockerignore index abc62d2..38718a6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,7 +7,5 @@ extension/ website/ scripts/ *.md -*.bat -*.sh .env server/.env diff --git a/AI_INIT.md b/AI_INIT.md index 13923f3..c240907 100644 --- a/AI_INIT.md +++ b/AI_INIT.md @@ -25,7 +25,7 @@ KoalaSync is a specialized tool for **synchronized video playback** across multi > [!IMPORTANT] > **Single Source of Truth**: `shared/constants.js` and `shared/blacklist.js` are the master files. They must be synchronized to the `extension/shared/` directory using `node scripts/build-extension.js`. > - **Extension Modules** (`background.js`, `popup.js`) import directly from `./shared/constants.js`. -> - **Content Scripts** (`content.js`) use a **manual synchronous mirror** to prevent race conditions during page load. Always verify parity after sync. +> - **Content Scripts** (`content.js`) use a **marker-injected synchronous copy** of the constants. The build script automatically replaces the marked blocks — no manual mirroring needed. ## 3. Mandatory Reading Before touching any code, you MUST read the following documents in order: @@ -36,10 +36,20 @@ Before touching any code, you MUST read the following documents in order: ## 4. The "Vanilla JS Mirror" Pattern To avoid boot-time race conditions in Manifest V3 without a bundler, the following architectural trade-off is enforced: - **Synchronous Execution**: `content.js` MUST execute synchronously to catch early media events. -- **Manual Mirroring**: `content.js` maintains a manual mirror of the `EVENTS` constants from `shared/constants.js`. -- **Maintenance**: Developers must ensure that any changes to `shared/constants.js` are manually reflected in `content.js` after running the build script. +- **Automated Injection**: The build script (`node scripts/build-extension.js`) automatically injects `EVENTS` and `HEARTBEAT_INTERVAL` into `content.js` using marker-based replacement (see `scripts/README.md` for marker details). +- **Maintenance**: After modifying `shared/constants.js`, simply run the build script. No manual mirroring is required. -## 5. Design Guidelines +## 5. File Responsibility Map + +| File | Responsibility | +|:-----|:---------------| +| `background.js` | WebSocket client, state orchestrator, event router, session persistence | +| `content.js` | Video element detection, media control, event origin detection (loop prevention) | +| `popup.js` | UI rendering, user input handling, peer display, invitation link generation | +| `bridge.js` | Landing page ↔ extension communication for invitation join flow | +| `server/index.js` | Room management, message relay, rate limiting, authentication, peer lifecycle | + +## 6. Design Guidelines The popup UI follows a strict design system. Do not modify these variables or the layout structure without explicit approval. - **Font**: System font stack. **MANDATORY**: No external CDNs or Google Fonts to ensure 100% privacy. - **Popup Width**: Fixed at `320px`. @@ -53,7 +63,7 @@ The popup UI follows a strict design system. Do not modify these variables or th | `--success` | `#22c55e` | Success states / Online dot | | `--error` | `#ef4444` | Errors / Offline dot | -## 5. Non-Negotiables (Core Logic) +## 7. Non-Negotiables (Core Logic) The following features are critical and must not be removed or fundamentally altered: - **Two-Phase Force Sync**: The `Prepare` → `ACK` → `Execute` flow ensures all peers are buffered before playback resumes. - **Episode Auto-Sync**: Ensures series binges stay perfectly synced. A lobby initiates during title transitions, freezing peers until everyone is ready. @@ -67,21 +77,22 @@ The following features are critical and must not be removed or fundamentally alt - **SW Keep-alive**: Use of `chrome.alarms` to prevent the Manifest V3 Service Worker from suspending. - **Diagnostics**: The "Dev" tab provides real-time access to the underlying `