Build S2: WritingLock — kiosk, chrome integration, unbroken typing #162
Notifications
Due Date
No due date set.
Blocks
Depends on
#163 Calibration gate: does the Cold Turkey lock rule calm?
AlexKucera/museion
#159 Cold Turkey lock mechanics — macOS kiosk factsheet (probe)
AlexKucera/museion
#161 Build S1: Cold Turkey goal engine — net-words delta + countdown
AlexKucera/museion
Reference: AlexKucera/museion#162
Reference in new issue
Block a user
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.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]
Research landed (#159 factsheet, closed): build against the pinned recipe — 6-option combo (
.hideDockrider first), options set BEFOREtoggleFullScreen, invalid combos throwNSInvalidArgumentException; ⌘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]
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 timeupdate(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]
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 →.terminateCancelwhile locked — the refusal IS the lock).FocusChrome.swiftgrows 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.cancelActionbutton (the ⌘S rail —.onExitCommandnever fires behind the hosting view, the #109 probe).isFocusednever 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.ProseTextView.onTextChange(both editor modes) →gate.writingLock.feed(text:)per keystroke; baseline =PostsModel.editorBodyTextat Start.canArmWritingLockmirrors 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 → falsefor ⌘W. macOS SwiftUI has no.closeItemCommandGroupPlacement (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 inWritingLockTests.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]