Repository navigation
feat(mecatui): wrap + scroll permission-modal args, full-screen ask-args view (#488) - #553
Merged
Merged
Conversation
jbeda
marked this pull request as draft
August 15, 2026 00:17
jbeda
force-pushed
the
488-permission-modal-args-wrap
branch
from
August 15, 2026 04:27
193b6f1 to
102c086
Compare
6 of 7 tasks
jbeda
force-pushed
the
488-permission-modal-args-wrap
branch
2 times, most recently
from
August 15, 2026 16:53
0f905a7 to
bd5d55b
Compare
jbeda
marked this pull request as ready for review
August 15, 2026 16:56
…rgs view (#488) The permission modal rendered a non-diff ask's args as one unwrapped pretty-JSON blob, so a long Bash command ran off the approval card and the operator authorized commands they could not read. Two tiers now: the modal's args region soft-wraps (ansi.Wrap + Hardwrap backstop) into a capped mini-viewport (10 rows; arrows/pgup/pgdn + wheel over the card scroll it; a fixed hint line advertises ctrl+t full args), and ctrl+t routes by ask type — non-diff asks open a full-screen scrollable ask-args view (argsVP, mirroring the plan-review pattern) with the generic verdict buttons pinned; Edit/Write keep the in-modal diff expand; plan asks untouched. Verdict keys fire from inside the view; esc/ctrl+t return to the modal. A rebindable RawArgs key (default bare r) toggles pretty (decoded {"command":...} + muted timeout_ms annotation) vs raw (the VERBATIM sanitized wire string — the approval-integrity floor). The command renders in a bright askArgs style with a tool-coloured left accent bar; a soft wrap carries a warning-coloured trailing ↩; the card sizes to content up to 132 columns and stays put while scrolling (the block width pins to the widest line over the whole content, not the visible window). Click geometry is a region-emitting registry (the click half of #555): each approval surface's regions are computed from the SAME layout builders the render path uses, with the buttonsRow travelling inside the builder's return value — one source, no skew; clickAt looks up, dispatchClick executes, and the wheel gate + hit-test share one approvalCardRect. MECATUI_DEBUG_ASK=1 registers an env-gated /debug-ask builtin (never a --help flag) cycling three canned long-args asks through the real reducer; a debug ask resumes the phase it interrupted (askResumePhase) rather than a dead running phase. ADR 0108 records the ctrl+t routing rule, the raw/pretty tier decision, and the wrap-marker convention. Co-Authored-By: mecatl <[email protected]>
jbeda
force-pushed
the
488-permission-modal-args-wrap
branch
from
August 15, 2026 17:33
bd5d55b to
b4d87ed
Compare
jbeda
added a commit
that referenced
this pull request
Aug 18, 2026
* refactor(mecatui): carve approval modal into domain-owned files (#555 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]> * refactor(mecatui): dedupe approval resume clamp; stdlib min/max/slices (#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]> * test(mecatui): pin the three approval invariants the goldens miss (#555 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]> --------- 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
Fixes #488. The permission modal rendered a non-diff ask's args as one unwrapped pretty-JSON blob, so a long Bash command ran off the approval card and the operator authorized commands they couldn't read.
Two tiers now:
ansi.Wrap+ansi.Hardwrapbackstop for unbreakable tokens) into a mini-viewport, scrollable via arrow/pgup/pgdn and the mouse wheel while the cursor is over the card. A fixed hint line advertisesctrl+t full args(plus a… scrollclause when rows are hidden).ctrl+ton a non-diff ask opens a scrollable ask-args view (mirrors the plan-review pattern:argsVPviewport + pinned generic verdict bar). Verdict keys fire from inside the view;esc/ctrl+treturns to the modal.Raw ⇄ pretty toggle (inside the full-screen view only, rebindable
RawArgs, default barer):{"command":…}to the command text (unescaped, deliberately no shell reformatting — no mvdan dep) + a mutedtimeout_ms: Nannotation when the envelope carries one; other tools fall back toprettyJSON.Presentation: the command renders in a bright
askArgsstyle with a tool-coloured left accent bar so it reads distinct from the muted reason/hint metadata; a soft-wrapped logical line carries a warning-coloured trailing↩at the end of each continued row (both surfaces) so a wrap is never mistaken for a real newline; the card sizes to content up to 132 columns (stable across scrolling — the block width pins to the widest line over the whole content, not the visible window) and the in-card cap is 10 rows.Review map
The change reviewed through a 6-agent panel (spec / standards / security / architecture / duplication / reuse) + a QA test-adequacy pass, then iterated through hand-testing rounds. Where to look, in priority order:
cmd/mecatui/ui/clickgeom.goapprovalClickRegionsclickAtis a lookup;dispatchClickis the single executor; the wheel gate and hit-test share one card-rect source (approvalCardRect). This refactor is the click half of #555 and replaced the old per-surfaceaskButtonAtarms.update.goonExpandToolsKeyexpandTools); Edit/Write → in-modal diff expand (unchanged); plan ask → untouched. ADR 0108 records this so a future change can't silently un-split it.permission.goaskArgsContenttimeout_msannotation.keys.go(RawArgs),keymap/validator.gorules 3b/3cRawArgsshares defaultrwith overlay-internalRefreshin disjoint surfaces; validator rejects explicit rebinds that re-overlap the pair OR shadow a rebound verdict chord inside the view.builtins.go/debug-ask, gated byMECATUI_DEBUG_ASK=1env (never a flag, stays out of--help)docs/tui.md,user-docs/what-you-get/{mecatui,permissions}.md,docs/design/IMPLEMENTATION-NOTES.md, newdocs/adr/0108-mecatui-ask-args-view.mdBugs caught by hand-testing (each pinned by a regression test)
/debug-askat idle resumed into a deadphaseRunning(spinner forever, no run behind it).advanceAsknow resumes the phase the ask interrupted (askResumePhase).askVPOffsetbut the frame never changed:renderPermissionModalhardcodedargsOffset: 0(only the hit-test threaded it). Now threaded; regression test drives pgdn through the realonKeydispatch.ctrl+t full argshint rendered only when rows were hidden; it is now unconditional on non-diff asks.Golden-test hygiene
Churn is exactly the two help goldens (new modal-keys section) + the
askargs_*goldens.view_*/zerostate_*stayed clean except one round where a restructure dropped the diff-path reason line — theview_strippedgolden caught it and it was restored in the same fix.Try it by hand
Preview frames without running:
cat cmd/mecatui/ui/testdata/askargs_*.golden.Follow-ups filed
/debug-*builtins)&&/||clause segmentation, mvdan/sh pretty-print decision)Non-goals
Heredoc syntax highlighting; clause segmentation; general debug-mode apparatus; scrollback tool-card wrap markers (the
↩is approval-surface-scoped for now); any change to the Edit/Write diff path, plan-review view, or wire/proto surface.