# HANDOFF — Session State ## Branch / Commit State **`main`**, working tree is **CLEAN**. `origin/main` == `1f4624c` (pushed). **Pushed** (reached `origin/main` == `1f4624c`, incl. tags): Phase 1 commit `0` + refactor commits `1..11`, **and Phase 2 commits `12..18`** (they were pushed at the Phase-2 milestone; the old "Phase 2 local-only" claim below was written before that push and is stale). **LOCAL ONLY (Phase 3 — A, B, C, D, E) + the Controls doc commit** — policy 2026-08-30: no per-commit push; `git push` only at a user-agreed milestone / "push it". **Push pending on explicit user approval:** | Commit | Hash | Tag | Payload | |--------|------|-----|---------| | docs | `cb54637` | — | `Controls/index.md` (missing per-directory map) | | A | `6944db8` | `refactor-commit-A` | split `MainViewModel.cs` core → **495** | | B | `31362d1` | `refactor-commit-B` | split `MainViewModel.Streaming.cs` → **330** | | C | `fab2e09` | `refactor-commit-C` | split `MainViewModel.Background.cs` → **418** | | D | `d3271a0` | `refactor-commit-D` | trim `SocialsDialogViewModel.cs` → **334** | | E | `dcb3637` | `refactor-commit-E` | split `LayoutStore.cs` → 6 partials, **≤495** | ## What's In Flight Nothing code-in-flight — working tree clean, **Phase 3 complete**. **Phase 3 result:** every production `.cs` is now **≤ 500 lines** (checked via `git ls-files '*.cs'` minus tests; nothing exceeds 500). The 500-line count is a **hard ceiling, not the goal** — each file was split **grouped by functionality** so an AI can process one concern per file. Splits were **concern-driven**: - `MainViewModel` → `.Sources.cs`/`.Web.cs`, `Streaming.cs` + `Streaming.Operations.cs`, `Background.cs` + `Background.Model.cs`; `SocialSlotViewModel.cs` (row VM). - `LayoutStore` (was 1402) → `Migrations.cs`/`Load.cs`/`Save.cs`/`Settings.cs`/ `Assets.cs` + a 47-line shell; `public partial class LayoutStore : IDisposable`. Every change: 0-warning build, `scripts/verify.sh` (246 pass + 2 known only), explicit-file `scripts/scope-check.sh`, `ViewModels/index.md` tracker in the SAME commit, tagged `refactor-commit-N`, no per-commit push. **Next:** - If user says "push": `git push origin main && git push --tags` (6 commits: `cb54637` + A–E, and tags `refactor-commit-A..E`). **Pending bus:** `ViewModels/index.md` Phase 3 tracker has rows A–E (closed); Phase 3 marked COMPLETE. Watch-list (under limit, no action): `Controls/PreviewPane.xaml.cs` (464), `ViewModels/MainViewModel.Audio.cs` (408). ## Landmines - **Pre-existing test failures (do not chase):** `AudioPipelineTests.Mix_HonorsProviderGains_AndGameMute_KillsTheLoopback` + `RoundClipInteractionTests.Round_Clip_Corner_Is_Grabbable_And_Shape_Is_Circle`. - **Tests occasionally abort early (236/237)** — known flake, accepted by `verify.sh`. - **App running locks `ytLive.exe`** → build fails MSB3027. Kill PID before building. - **WinForm crash from `Window_PreviewMouseLeftButtonDown`** — handled in-side the preview/left panel; don't add handlers that deref `OriginalSource` unguarded. - **Controls cannot see `Window.Resources`** (converter rule, Commit 13): any StaticResource the window once supplied must live at app level in `Themes/Controls.xaml`. The 7 converters were promoted there. - **Some control XAML needs its own `xmlns:models` / `xmlns:Helpers`** — a moved block lost its namespace when it left MainWindow's root (LeftPanel hit this, MC2000 "key null"). Always add the model/helper xmlns on each control root. - **Name-looked-up host stubs must stay in the window:** `WebViewHostPanel` (ctor `InitWebView2(WebViewHostPanel)`) and `ToastArea` (`NotificationService.InArea("ToastArea")`) are resolved by name from the window — keep them as window-root children, don't bury them in a control. OverlayHost deliberately left them in place (Commit 18) for this reason. - **Pre-commit gate:** `scripts/verify.sh` (0-warning build + full tests) and `scripts/scope-check.sh "file1" …` — scope-check REQUIRES explicit file args. - Build from WSL with the Windows dotnet host only (see `AGENTS.md`). ## Todo state - MainViewModel refactor: **Phase 1 complete (11/11 partials)**, pushed. - MainWindow.xaml refactor: **Phase 2 complete (6/6 controls)**, pushed at `1f4624c`. - 500-line compliance: **Phase 3 complete (all 5 offenders ≤ 500)**, local-only A–E. - TASK 3: 27/30 (preview compositor 16, text source 17, alerts 20 still open). - TASK 4: ✅ shipped. TASK 9: items 1–3 shipped; 4–7 open. TASK 10: steps 1–7; Velopack pending. - TASK 18: shipped, creator verification pending. TASK 19/23, 20, 21-A: shipped. - TASK 22 (audio sync offset): not started — required for v1. ## Session summary (2026-08-31) - Ran the **500-line Phase 3 split to completion** under the standing "continue without stopping" directive — no interruption prompts, no `question` tool. - Commits A–E landed locally, each: cut → 0-warning build → verify (246 pass + 2 known) → scope-check → index.md in-commit → `git tag refactor-commit-{A..E}`. - **Re-structuring principle (user correction, 2026-08-31):** split by **functionality**, so an AI can process one concern per file; the 500-line count is a **ceiling**, NOT the target. Do not pad or reshape code to a number — group by concern and only split enough to stay under the ceiling. - **Commit E (LayoutStore)** the biggest: 1402 → 6 concern-based partials (Migrations/Load/Save/Settings/Assets/shell), default partial split. - **Accident caught & recovered (Commit D):** a `> ViewModels/SocialsDialogViewModel.cs` write that read from the file it was simultaneously truncating left the file at 1 line. Fixed IMMEDIATELY via `git checkout --` and re-ran the split. **Lesson** (goes in `MyMistakes.md`): never `awk … > SRC` where `awk` also reads `SRC`; stage every multi-block cut into temp files first, then assemble. All later LayoutStore cuts did exactly that (read original once into temp files). - Push checkpoint reached; awaiting explicit "push" for `cb54637` + A–E + tags.