# Context (synthesized from SPEC §1, §9 and DOC)

Background, stakeholders, scope boundaries, and developer-facing operational
context. Functional requirements are in `requirements.md`; technical decisions
are in `decisions.md`; non-functional constraints are in `constraints.md`.

---

## Topic: Project goal

- Source: `Тз расширение фаза1.md` §1 (Контекст и цель)
- Notes:
  - Operators work inside a browser and periodically make mistakes that are
    hard to diagnose after the fact.
  - The goal of Phase 1 is to silently and continuously record an operator's
    session so that, on a button press, a self-contained archive of the
    session can be exported to the "Downloads" folder for handoff to support.
  - Phase 1 is local-only; no server, no AI, no auto-ticketing.

---

## Topic: Phase 1 scope (what is in)

- Source: `Тз расширение фаза1.md` §4, §5, §6, §7, §10; `README.md` §"Особенности"
- Notes:
  - Continuous in-memory recording of:
    - Last 30 s of active-tab video (`chrome.tabCapture` + MediaRecorder)
    - Last 10 min of DOM events via rrweb (cap 5 000 events)
    - Last 10 min of user/runtime events (click, input, navigation, js_error,
      network_error)
  - One-shot screenshot at export time (`chrome.tabs.captureVisibleTab`).
  - Local ZIP packaging via JSZip and delivery via `chrome.downloads`.
  - Sensitive-data masking for passwords and `[data-sensitive="true"]` fields.
  - Single-button popup UI with idle / saving / done state machine.

---

## Topic: Phase 1 non-goals (Phase 2 work)

- Source: `Тз расширение фаза1.md` §9 (Что НЕ входит в Фазу 1)
- Notes — explicitly excluded from Phase 1 and reserved for Phase 2:
  - Sending data to a server
  - AI-driven diagnostics
  - Automatic ticket creation
  - Analytics dashboard
  - Audio recording

---

## Topic: Developer workflow (install, build, debug)

- Source: `README.md` §"Установка и запуск", §"Отладка", §"Структура проекта"
- Provenance: This topic is DOC-only — the SPEC does not specify a build
  toolchain. Per precedence `SPEC > DOC`, any future SPEC/ADR that prescribes a
  different toolchain auto-overrides what is recorded here.
- Notes:
  - **Install deps:** `npm install`
  - **Dev build with HMR:** `npm run dev`
  - **Prod build:** `npm run build`
  - **Load in Chrome:**
    1. `npm run build`
    2. Open `chrome://extensions/`
    3. Enable Developer mode
    4. "Load unpacked"
    5. Select the `dist/` folder
  - **Debugging entry points:**
    - Service Worker: Chrome DevTools → Extensions → Service Worker → Console
    - Content Script: Chrome DevTools on the page → Console
    - Popup: right-click popup → "Inspect"
  - **Project layout (DOC-described, may be stale relative to actual repo):**
    ```
    ai-call-extension/
    ├── src/
    │   ├── background/          # Service Worker
    │   │   └── index.ts
    │   ├── content/             # Content Script
    │   │   └── index.ts
    │   ├── popup/               # Popup UI
    │   │   ├── index.html
    │   │   ├── index.ts
    │   │   └── style.css
    │   └── shared/              # Common types + utilities
    │       ├── types.ts
    │       └── logger.ts
    ├── icons/
    ├── dist/
    ├── manifest.json
    ├── vite.config.ts
    ├── tsconfig.json
    └── package.json
    ```

---

## Topic: User-facing flow

- Source: `Тз расширение фаза1.md` §5; `README.md` §"Использование"
- Notes:
  1. First popup open requests screen-recording permission (mandatory).
  2. Recording starts automatically once granted.
  3. To file an error report:
     - Click the extension icon.
     - Click "Сохранить отчёт об ошибке".
     - Archive lands in the user's "Downloads" folder automatically.
  4. Button state cycle: `idle` → "Сохраняю..." → "Готово! ✓" → `idle`
     (3 s revert).

---

## Topic: Licensing and support

- Source: `README.md` §"Лицензия", §"Контакты"
- Notes:
  - License: **MIT**
  - Support contact: addressed to "support" (no concrete channel listed in
    DOC).

---

## Topic: Russian-source provenance

- Source: both documents (`Тз расширение фаза1.md`, `README.md`)
- Notes: Both source documents are authored in Russian. UI strings ("Сохранить
  отчёт об ошибке", "Последние 30 сек видео + 10 мин лога", "Сохраняю...",
  "Готово! ✓") are part of the user-facing contract and MUST be preserved
  verbatim. Section identifiers and technical names use Latin script.
