Repository navigation
refactor(mecatui): approval modal consolidation (#555 Phase 1) - #608
Merged
Merged
Conversation
…Phase 1) The approval modal's state and behavior were scattered across six files split by technical layer (model.go fields, update.go reducers, permission.go renderers, clickgeom.go hit-test, view.go render arm, keys.go bindings). That spread is the drift point PR #553 exposed — a single feature touched the render path and the hit-test arm in two places and got them out of sync. Phase 1 consolidates the modal into four domain-owned files, no behavior change: - approval_state.go — the approvalState value (ask, FIFO queue, dedupe set, plan/args viewport clusters) and its pure queue-manipulation methods. Model now holds ONE `approval approvalState` field instead of ~12 loose fields; resetSession/endRun collapse to approval.reset(). - approval_surface.go — the reducers/handlers, split into a pure surface half (mutates approvalState, returns []approvalAction) and thin Model shims that execute the actions (the wire send, the transcript notice, the phase transition, the spinner re-arm). The modal no longer calls the wire directly — the surface proposes, the Model disposes. approvalDeps is the explicit five-field list of what the surface may touch, built per call, never stored; no *Model back-reference. - approval_render.go — the renderers/builders (formerly permission.go) + renderApprovalBody. - approval_regions.go — the mouse hit-test geometry. The keymap bindings (Allow/Deny/RawArgs) stay Model-global vocabulary; the phase value and the phase<->ask invariant stay Model-side. Structural gate: approval_arch_test.go fails CI if an approval-vocabulary declaration lands outside the four files, or if Model grows a second approvalState field. Verification: task test, task lint, task docs all green; the frame goldens TestViewGoldenStripped/TestViewGoldenAztecANSI pass unmodified; the spinner re-arm contract (TestResolveLastAskRearmsSpinner, TestSpinnerVisibleMatchesFooterRender) is intact. go run ./cmd/mecademo prints the full offline session. Co-Authored-By: mecatl <[email protected]>
#555 review) Panel-review follow-up to Phase 1. The cross-confirmed Domain finding: approvalState.advance() already clamps adv.resume to idle|running, and the three Model-side consumers re-applied the identical `if resume != phaseIdle { resume = phaseRunning }` — one resume invariant living in four places, dead code that would silently diverge if the rule ever changed. Delete the three consumer copies and trust advance()'s contract (the single source of truth). Mechanical cleanups from the same pass: - miniScroll + permissionModalBodyParts clamps → max(0, min(...)) builtins. - askQueueIndex → slices.IndexFunc. - drop the dead Model markAskResolved shim (only a test used it; it now calls approvalState.markAskResolved directly). - fix the arch-gate regex's dead advanceAsk token (the symbol is advance()). approvalAction's open-* payload (ask/queued/model) is deliberately KEPT: it makes the action self-describing for any future non-immediate dispatch (the out-of-order-approval direction discussed in review), at the cost of a today-redundant copy. Documented in the PR. task test / task lint green; goldens unmodified. Co-Authored-By: mecatl <[email protected]>
… review) The QA/test-adequacy pass on Phase 1 found three behaviors the frame goldens do not pin — axes a "pure migration" could silently break while the suite stays green. Add executable oracles for each: - TestPlanReviewNoOpRepopulationPreservesOffset / TestArgsViewRawToggleRepopulates: the planVP/argsVP fingerprint no-op-repopulation guard (a dropped fingerprint would re-SetContent and yank the operator's reading position, invisible to a single-frame golden). Verified the plan test FAILS when the guard's fingerprint term is removed, so it pins the behavior, not just the code. - TestDebugAskResolveNilStreamNoPanic: the /debug-ask-from-idle nil-stream resolve path — the sendApproval dep must return nil, not panic, and the notice must still land. The one path no golden executes. - TestPhaseAskIDBiconditional: the documented `phase==phaseAwaitingApproval ⟺ ask.AskID != ""` invariant swept across open / enqueue / resolve-successor / resolve-drain / retract-visible. The arch gate is placement-only; this is the behavioral pin. task test / task lint green; goldens unmodified. Co-Authored-By: mecatl <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Phase 1 (Milestone 1) of #555: carve the mecatui approval modal out of its six-file, technical-layer spread into four domain-owned files, so a change to the modal touches one place instead of a phase flag, a
renderBodyarm, anonKeybranch, a wheel branch, a hit-test arm, a lifecycle clear, and a help listing held in lockstep.No behavior change. Frame goldens (
TestViewGoldenStripped,TestViewGoldenAztecANSI) pass unmodified;task test,task lint,task docsall green.The shape
approval_state.goapprovalState(ask, FIFO queue, dedupe set, plan/args viewport clusters) + pure queue methods.Modelnow holds oneapproval approvalStatefield;resetSession/endRuncollapse toapproval.reset().approval_surface.go[]approvalAction) + thin Model shims that execute them.approval_render.gopermission.go) +renderApprovalBody.approval_regions.go#553region-registry vocabulary stays shared inclickgeom.go).permission.gois deleted (83% renamed toapproval_render.go).Locked decisions (driving the shape)
approvalDeps: the explicit five-field list of what the surface may touch (theme,keys,sendApproval,notice,sessionID), built per call, never stored. No*Modelback-reference.keys.go); a surface's renderer advertises which it consumes.resolveAsk/applyPermissionAskreturn actions; the shim doesstream.SendApproval/conv.addNotice/ the phase assign +sp.Tickre-arm. The modal no longer calls the wire. This is the Elm/Redux-slice pattern, and it's what makes the modal testable without a live stream.approval_arch_test.gois a loud structural gate: fails CI if an approval-vocabulary declaration lands outside the four files, orModelgrows a secondapprovalStatefield.m.phaseand thephase ⟺ ask.AskID != ""invariant stay Model-side (they gate the whole Model, not just the modal).Why this is the conventional shape
Surface-as-pure-function-over-state emitting actions that the caller executes is the Elm Architecture (Bubble Tea's own model) taken one level down — the same as Redux slices (state + reducer + action values) and VSCode workbench parts (own view + contribution, registry composes). What we avoid is a retained-mode widget tree with a back-pointer. Phase 2's surface stack (modal exclusivity by z-order, top owns the frame) layers onto this.
Phase-2 handoff
The four-file split is the boundary the
surfaceinterface will formalize:Render≈renderApprovalBody,Regions()≈approvalClickRegions,HandleKey/HandleWheel≈onApprovalKey/approvalWheel,Close()≈reset().approvalDepsis the template for each surface's deps. The two things deliberately kept Model-side —m.phaseandrefreshView()— are what Phase 2 must decide whether to formalize. The arch gate becomes the per-overlay checklist for the inventory-overlay migration.Verification
task test/task lint/task docs: green-update)TestResolveLastAskRearmsSpinner,TestSpinnerVisibleMatchesFooterRender)go run ./cmd/mecademoprints the full offline session