Files
museion/docs/devlog/20261008-issue84-view-menu-doubled_log.md
T
2026-10-08 21:31:05 +02:00

50 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# View Menu doubled (#84)
> **Date:** 2026-10-08
> **Type:** issue
> **Reference:** https://git.babylondreams.de/AlexKucera/museion/issues/84
## Goal
Kill the doubled View menu: "Toggle Reading Mode" (#68) lived in its own `CommandMenu("View")`, putting a second View menu in the menu bar beside the system one. The toggle must keep working (⌘R, `.toggleReadingMode` notification).
## What Was Done
- `Museion/MuseionApp.swift` — swapped `CommandMenu("View")` for `CommandGroup(after: .toolbar)`, so the reading toggle joins the system View menu instead of creating a duplicate. Button, shortcut, and notification post untouched.
- `MuseionTests/MuseionTests.swift` — new test `single View menu hosts the reading toggle`: hosted in the real app, inspects `NSApp.mainMenu`, asserts exactly one View-titled top-level menu and that it carries the item.
- TDD verified: test RED against the original code (two View menus — real assertion failure), GREEN with the fix. Full suite (unit + UI smoke) green; SwiftLint 0 violations on both files.
- Reviews: implement-skill review (standards: approve; spec: PASS, no findings) and finish-audit fanout (security STRIDE: 0 findings; general: 0 actionable; ponytail: 2 comment shrinks, applied — net −6 comment lines).
## Decisions & Rationale
| Decision | Rationale |
|----------|-----------|
| `CommandGroup(after: .toolbar)` over other placements | The platform way to append into the system View menu (after the Toolbar section); `CommandMenu("View")` is a *new* top-level menu by definition — that was the whole bug. |
| Discriminate on View-titled menu **count**, not contents | The system View menu's items are context-lazy (absent without a toolbar), so in the hosted test it can legitimately hold only our item. Counting View-titled menus catches the duplicate both ways. |
| Test via `NSApp.mainMenu` in the hosted suite | MuseionTests runs inside the real app process, so the live menu bar is assertable — no UI-test machinery needed for a structural claim. |
## Gotchas & Fixes
| Problem | Root Cause | Fix |
|---------|------------|-----|
| First GREEN run still failed (`items.count > 1`) | System View items are context-lazy; the merged menu held only our item in the test host. Probe (dumped menu tree to /tmp) showed one `[View]` menu — the fix itself worked, the assertion was wrong. | Assert `viewMenus.count == 1` + item present. |
| `-only-testing:MuseionTests/MuseionTests` matched 0 tests, "TEST SUCCEEDED" | Swift Testing free functions aren't class-scoped; the filter silently matched nothing — a 0-test success. | Filter at target level (`-only-testing:MuseionTests`), or grep the log for the test-case line. |
| `swiftformat .` reformatted 17 untouched files | Repo-wide format pass touches pre-existing drift in other files. | `git checkout` the collateral; lint only the two changed files. |
| Stash-RED run reported failure but no test line | The RED failure was a compile error (optional `NSApp.mainMenu` used unwrapped) — caught by reading the log, not the summary. | `try #require(NSApp.mainMenu)` in the test. |
| First review fanout dispatch failed ("670 tasks" runaway guard) | Malformed delegate_task payload from an earlier turn. | Re-dispatched cleanly; user said continue. |
## Files Changed
| File | Change Summary |
|------|---------------|
| `Museion/MuseionApp.swift` | `CommandMenu("View")` → `CommandGroup(after: .toolbar)`; comment update |
| `MuseionTests/MuseionTests.swift` | +import AppKit; new test pinning one View menu |
## Open Items & Next Steps
- None. `PRD.md` carries a pre-existing unrelated modification — left untouched on purpose.
---
*Log written by write-log skill*