Build S2: WritingLock — kiosk, chrome integration, unbroken typing #162

Closed
opened 2026-11-04 11:02:00 +01:00 by AlexKucera · 3 comments
Owner

Question

The integration slice: wire the goal engine (S1) and the contract render (prototype) into the app.

  • WritingLockState (lock ⇒ focus invariant): armed → locked → complete; refuse ⌥⌘F and focus exit while locked (the refusal IS the lock); suppress the #87 hover-reveal zones (library + mentor stay hidden); the open Piece is stable for counting.
  • Kiosk per the research factsheet: fullscreen entry at lock start, presentation-options pairing, previous window size restored at completion; quit mid-block dies quietly (no persistence — settled).
  • Arm-bar + progress readout per the contract render; menu item "Start Cold Turkey…" (focus-mode-gated); completion note on quiet return to focus.
  • Hard AC (2026-11-04, Alexander): typing is never interrupted by the unlock transition — no editor remount, no first-responder loss, no caret/scroll jump mid-thought. Mechanism per the research factsheet (direct exit if clean, else defer geometry to typing idle).
  • Save-failure stays visible while locked (#87 floating cue); drafts keep ⌘S.
  • Editor-only while locked: passes and chat unreachable.

AC: suite green (count executed tests); focus-mode behavior unchanged when no lock is armed; devlog per convention. Blocked by the research factsheet (kiosk recipe), the prototype (contract), and S1 (engine).

Part of #158

[Generated by AI]

## Question The integration slice: wire the goal engine (S1) and the contract render (prototype) into the app. - `WritingLockState` (lock ⇒ focus invariant): armed → locked → complete; refuse ⌥⌘F and focus exit while locked (the refusal IS the lock); suppress the #87 hover-reveal zones (library + mentor stay hidden); the open Piece is stable for counting. - Kiosk per the research factsheet: fullscreen entry at lock start, presentation-options pairing, previous window size restored at completion; quit mid-block dies quietly (no persistence — settled). - Arm-bar + progress readout per the contract render; menu item "Start Cold Turkey…" (focus-mode-gated); completion note on quiet return to focus. - **Hard AC (2026-11-04, Alexander)**: typing is never interrupted by the unlock transition — no editor remount, no first-responder loss, no caret/scroll jump mid-thought. Mechanism per the research factsheet (direct exit if clean, else defer geometry to typing idle). - Save-failure stays visible while locked (#87 floating cue); drafts keep ⌘S. - Editor-only while locked: passes and chat unreachable. AC: suite green (count executed tests); focus-mode behavior unchanged when no lock is armed; devlog per convention. Blocked by the research factsheet (kiosk recipe), the prototype (contract), and S1 (engine). Part of #158 [Generated by AI]
AlexKucera added the wayfinder:task label 2026-11-04 11:02:00 +01:00
AlexKucera added a new dependency 2026-11-04 11:02:14 +01:00
Author
Owner

Research landed (#159 factsheet, closed): build against the pinned recipe — 6-option combo (.hideDock rider first), options set BEFORE toggleFullScreen, invalid combos throw NSInvalidArgumentException; ⌘Q/⌘W via delegate refusals (applicationShouldTerminate → .terminateCancel, windowShouldClose → false), no menu surgery; fullscreen is a UX commitment only — the lock holds windowed too. Typing-continuity hard AC: direct fullscreen exit preserved first-responder identity in the probe — build the direct exit, no idle-deferral machinery.

[Generated by AI]

Research landed ([#159 factsheet](https://git.babylondreams.de/AlexKucera/museion/issues/159), closed): build against the pinned recipe — 6-option combo (`.hideDock` rider first), options set BEFORE `toggleFullScreen`, invalid combos throw `NSInvalidArgumentException`; ⌘Q/⌘W via delegate refusals (`applicationShouldTerminate` → `.terminateCancel`, `windowShouldClose` → false), no menu surgery; fullscreen is a UX commitment only — the lock holds windowed too. Typing-continuity hard AC: direct fullscreen exit preserved first-responder identity in the probe — build the direct exit, no idle-deferral machinery. [Generated by AI]
Author
Owner

Note from the #161 finish audit (security reviewer, informational): DraftStats.words(in:) materializes the full token array per call — O(n) allocations on the main actor each time update(text:) runs. Don't feed it per keystroke: throttle the lock's word count onto the readout tick (~250 ms) or another cadence ≥1 s. The rail itself stays as-is (semantics are the pinned shared contract).

[Generated by AI]

Note from the #161 finish audit (security reviewer, informational): `DraftStats.words(in:)` materializes the full token array per call — O(n) allocations on the main actor each time `update(text:)` runs. Don't feed it per keystroke: throttle the lock's word count onto the readout tick (~250 ms) or another cadence ≥1 s. The rail itself stays as-is (semantics are the pinned shared contract). [Generated by AI]
AlexKucera self-assigned this 2026-11-04 12:53:36 +01:00
Author
Owner

Resolution — built and green, 2026-11-04

The integration slice landed as an uncommitted working tree (map rule — landing needs Alexander's go).

What's wired:

  • WritingLockState.swift — the machine (start/feed/tick/complete, 1 s ticker, note fading ~6 s) + WritingLockKiosk (the #159 recipe verbatim: 6-option combo + .disableScreenCornerInteractions; already-fullscreen windows enter in place, exit replays only what entry toggled) + WritingLockAppDelegate (⌘Q/Quit/AppleEvents → .terminateCancel while locked — the refusal IS the lock).
  • FocusChrome.swift grows the one chrome lineage per the #160 baked contract: ColdTurkeySeat (arm-bar | readout | note — one bottom-center seat), bare mono seats, 2 px hairline, terracotta @80 % inside the last 20 %, piece title absent, Start the only boxed element. ColdTurkeyDot: persistent muted pip bottom-right, hover label, click arms. Esc = a hidden .cancelAction button (the ⌘S rail — .onExitCommand never fires behind the hosting view, the #109 probe).
  • The refusals: ⌥⌘F and Toggle Reading disabled while locked; New Post/Outline/Project, Open…, Import… and the window drop destination refused (the open Piece stays the counted one); hover-reveal zones suppressed (library + mentor stay hidden — editor-only, passes and chat unreachable).
  • Typing continuity (the hard AC) holds by construction: lock ⇒ focus means isFocused never flips mid-block, the CT chrome mounts as overlays only (the editor column's identity is untouched — the #87 hazard), and the #159 probe already verified the fullscreen round trip preserves first-responder identity. No deferral machinery needed, exactly as the factsheet predicted.
  • Feed + baseline: ProseTextView.onTextChange (both editor modes) → gate.writingLock.feed(text:) per keystroke; baseline = PostsModel.editorBodyText at Start. canArmWritingLock mirrors the editor branch's outline routing (outline pieces never arm; prose drafts, the guest, prose posts do).

One deviation from the factsheet, documented: #159 prescribed windowShouldClose → false for ⌘W. macOS SwiftUI has no .closeItem CommandGroupPlacement (compile-verified against the 27.2 swiftinterface) and owns the stock window delegate, so the delegate refusal is unreachable. ⌘W is instead swallowed by a local keyDown monitor installed/removed with the lock (the OutlineDrag monitor pattern — monitors resolve before menu key equivalents). Quiet, no dialog, no behavior change unlocked.

Judgement calls (flag for the gate): the external guest CAN arm (prose surface, counts fine); the View ▸ Start Cold Turkey… item is plain in the View group, not nested under a one-item Focus submenu; the Fix Cards palette window (separate space) isn't covered by the kiosk if open at lock start.

Verification: build SUCCEEDED; suite 617 executed / 617 passed / 0 failed, counted in the xcresult (Test-Museion-2026.11.04_13-14-24-+0100.xcresult) — baseline 601 at #161, +16 in WritingLockTests.swift (machine transitions, contract shapes, the 7-bit recipe, the canArm mirror, the lock ⇒ focus invariant). swiftformat clean; swiftlint 0 errors in app + test targets. Devlog: docs/devlog/20261104-issue162-cold-turkey-writing-lock-integration_log.md.

[Generated by AI]

## Resolution — built and green, 2026-11-04 The integration slice landed as an **uncommitted working tree** (map rule — landing needs Alexander's go). **What's wired:** - `WritingLockState.swift` — the machine (start/feed/tick/complete, 1 s ticker, note fading ~6 s) + `WritingLockKiosk` (the #159 recipe verbatim: 6-option combo + `.disableScreenCornerInteractions`; already-fullscreen windows enter in place, exit replays only what entry toggled) + `WritingLockAppDelegate` (⌘Q/Quit/AppleEvents → `.terminateCancel` while locked — the refusal IS the lock). - `FocusChrome.swift` grows the one chrome lineage per the #160 baked contract: `ColdTurkeySeat` (arm-bar | readout | note — one bottom-center seat), bare mono seats, 2 px hairline, terracotta @80 % inside the last 20 %, piece title absent, Start the only boxed element. `ColdTurkeyDot`: persistent muted pip bottom-right, hover label, click arms. Esc = a hidden `.cancelAction` button (the ⌘S rail — `.onExitCommand` never fires behind the hosting view, the #109 probe). - The refusals: ⌥⌘F and Toggle Reading disabled while locked; New Post/Outline/Project, Open…, Import… and the window drop destination refused (the open Piece stays the counted one); hover-reveal zones suppressed (library + mentor stay hidden — editor-only, passes and chat unreachable). - **Typing continuity (the hard AC) holds by construction**: lock ⇒ focus means `isFocused` never flips mid-block, the CT chrome mounts as overlays only (the editor column's identity is untouched — the #87 hazard), and the #159 probe already verified the fullscreen round trip preserves first-responder identity. No deferral machinery needed, exactly as the factsheet predicted. - Feed + baseline: `ProseTextView.onTextChange` (both editor modes) → `gate.writingLock.feed(text:)` per keystroke; baseline = `PostsModel.editorBodyText` at Start. `canArmWritingLock` mirrors the editor branch's outline routing (outline pieces never arm; prose drafts, the guest, prose posts do). **One deviation from the factsheet, documented:** #159 prescribed `windowShouldClose → false` for ⌘W. macOS SwiftUI has **no `.closeItem` CommandGroupPlacement** (compile-verified against the 27.2 swiftinterface) and owns the stock window delegate, so the delegate refusal is unreachable. ⌘W is instead swallowed by a local keyDown monitor installed/removed with the lock (the OutlineDrag monitor pattern — monitors resolve before menu key equivalents). Quiet, no dialog, no behavior change unlocked. **Judgement calls (flag for the gate):** the external guest CAN arm (prose surface, counts fine); the View ▸ Start Cold Turkey… item is plain in the View group, not nested under a one-item Focus submenu; the Fix Cards palette window (separate space) isn't covered by the kiosk if open at lock start. **Verification:** build SUCCEEDED; suite **617 executed / 617 passed / 0 failed, counted in the xcresult** (`Test-Museion-2026.11.04_13-14-24-+0100.xcresult`) — baseline 601 at #161, +16 in `WritingLockTests.swift` (machine transitions, contract shapes, the 7-bit recipe, the canArm mirror, the lock ⇒ focus invariant). swiftformat clean; swiftlint 0 errors in app + test targets. Devlog: `docs/devlog/20261104-issue162-cold-turkey-writing-lock-integration_log.md`. [Generated by AI]
Sign in to join this conversation.