Skip to content

feat(mecatui): migrate effort picker to a bounded modal surface - #2266

Merged
jbeda merged 4 commits into
mainfrom
impl/2170-effort-surface
Oct 11, 2026
Merged

jbeda merged 4 commits into
mainfrom
impl/2170-effort-surface

Conversation

@jbeda

@jbeda jbeda commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Migrate /effort to the shared modal surface contract, keeping fork-resume and session effects root-owned through a narrow selection intent.
  • Bound tier browsing with bounded.List and presentListRow, independent cursor/current markers, a content-sized card measured from the complete inventory and chrome, stable dimensions while browsing, resize selection reveal, and safe close-only/zero-size behavior.
  • Add standard remappable paging/endpoint navigation and selection-neutral wheel scrolling; share key-to-navigation translation with the compatible Memory and Sessions paths.
  • Add real-dispatch geometry, input ownership, handoff-ordering, and regression coverage; update contributor documentation and the picker golden.
  • Keep user docs focused on non-obvious behavior rather than repeating UI hints. Document general content-sized card guidance in docs/tui.md: width limits are ceilings, not mandatory sizes.

Standing authoring instructions and Docusaurus exclusions were extracted to #2267, which has merged. This PR contains no authoring-policy changes.

Closes #2170.

Advances #1742 (bounded browsing) and #2237 (surface ownership); neither parent tracker is complete. Click-to-select, other UI migrations, and #1485 are out of scope.

Verification

  • Full UI and bounded-control suites
  • task test
  • task test:race
  • task lint
  • task docs
  • go run ./cmd/mecademo — verified tool call, permission ask/approval, and final result
  • Four-axis panel review with targeted correction rechecks: no remaining findings or reviewer failures

Aggregate test gates passed with shorter system temporary paths after managed temporary paths exceeded Linux's Unix-socket pathname limit. Initial lint and review findings were corrected and rechecked, not waived.

The earlier documentation-only follow-up passed task docs, task site:build, and a focused editorial review. The content-sized card refinement passed the aggregate gates above and an incremental four-axis review. After test-only assertion strengthening, the full UI/bounded suites, focused sizing race tests, and lint were rerun successfully; product code, contributor guidance, and golden were unchanged by that assertion follow-up.

Implementation plan

Full reviewed implementation plan, archived in one conversation comment and verified against the latest local plan by readback and SHA-256. The plan remains ignored and uncommitted locally.

Address #2170 alongside surface ownership tracked by #2237. Share bounded navigation translation with Memory and Sessions.

Co-authored-by: Mecatl <[email protected]>
@jbeda

jbeda commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Implementation plan archive

  • Repository/PR: stacklok/mecatl feat(mecatui): migrate effort picker to a bounded modal surface #2266
  • Slug: 2170-effort-surface
  • Local source path (provenance only): .scratch/2170-effort-surface-plan.md
  • Implementation branch: impl/2170-effort-surface
  • Base: main; recorded branch start: c6d7338
  • Observed PR head: 2c6d442
  • Archive updated: 2026-10-11T22:17:00Z
  • SHA-256 of the full plan portion below: 193d9bdd913a06fbe8bdee741fbc7f4932bf4ac4dbfa9213121d4140517697ec

Amendments: user documentation was trimmed to omit duplicated UI instructions; standing authoring guidance/site exclusions were extracted to #2267, which merged. The operator then requested a smaller content-sized Effort card measured from the entire list and fixed chrome, with stable dimensions during browsing. docs/tui.md states the general rule: limits are ceilings, finite pickers use complete-inventory sizing, and larger inventories/text inspectors may use more width when useful. This is not an Effort-only exception. Terminal resize and existing compact/zero-size contracts remain intact.

This is the reviewed design snapshot with approved scope/sizing amendments, including planning-time facts and intended verification. Actual completed gate/review results are reported in the PR description; plan text does not establish runtime behavior. No plan content was omitted or redacted.


Effort bounded surface plan

Slug: 2170-effort-surface
Implementation branch: impl/2170-effort-surface
Base branch: main
Plan path: .scratch/2170-effort-surface-plan.md

Proposal only; no implementation authority. New plan for one slice of #1742 and #2237, implementing #2170. No branch or PR exists for this slug at planning time. Keep this file ignored and uncommitted.

Goal and decisions

Make /effort a geometry-bounded picker with surface-owned open-lifetime state and consistent browsing controls, in one PR. The user confirmed standard page/top/end keyboard navigation and wheel scrolling without selection changes, and requested reusable helpers where appropriate. Reuse bounded.List, presentListRow, and the existing modal/intent contracts; share the repeated input-to-navigation mapping rather than build a new widget framework.

Preserve F7 and /effort, idle/capability gating, the six tiers in existing order, server-resolved current marking, direct Enter fork-resume, provider/model preservation, auto -> empty wire value, and existing failure recovery. No confirmation step, click-to-select, model-picker redesign, server/credential/persistence changes, auto-effort bug #1485, other tracker slices, active conversation scrolling, or generic dependency-refresh framework. Shared helpers may replace equivalent navigation switches in Memory and Sessions, but do not normalize unrelated surface behavior.

Documentation amendment

The user requested concise user docs: use tech-writer and omit instructions readers can infer or already see in UI hints/help. Keep non-obvious wheel/selection semantics and remove duplicated Effort navigation walkthroughs. The standing authoring contract migration to scoped user-docs/AGENTS.md, its CLAUDE.md alias, reference updates, and Docusaurus exclusions are extracted to PR #2267, independently based on main, so it can merge first. Those policy/infrastructure changes are not part of the Effort PR #2266.

Established seams

  • cmd/mecatui/ui/effort.go: effortState currently lives on Model; openEffort, onEffortKey, chooseEffort, and renderEffortOverlay implement a legacy overlay. The renderer emits all six rows regardless of the offered height. effortValue, effortLabel, effortCursorFor, and effortSelection already encode sentinel/current/model-preservation behavior.
  • Model integration: model.go effort field; view.go effort render branch; update.go body ownership and legacy overlay key route; selection.go body-owner predicate. Generic modal routing already provides these roles once the picker uses m.modal. builtins.go:runEffort and the F7 handler call openEffort.
  • models.go:switchEffort owns persistence and fork-resume, retains the source projection, disarms its live feed, and enters connecting with a request token. switchEffortCmd forks then hydrates. update.go effort handoff reducers correlate token/source/phase, adopt the successor before closing the source, and restore the source on failure. These remain root-owned and unchanged in behavior.
  • surface.go defines surface, captured surfaceDeps, one-shot surfaceIntentSource, and parent-owned frame/placement. update.go:dispatchSurfaceKey prepares current geometry and applies an intent before common close processing; the existing stop-dispatch result allows a root effect to take over without unwanted common focus/close work.
  • bounded.List already owns stable item identity, selection reveal, window scrolling, geometry, and indicator reservation. List.Move selects/reveals; List.Scroll moves the window without selecting. Two gutter cells plus their trailing padding leave at least one text cell only at content width >= 4 (internal/bounded/list.go:SetGeometry, viewport.go:Valid). Do not duplicate this validity rule.
  • list_row.go:presentListRow owns cursor/status gutter and selected/unselected style. usermodel.go:userModelMove, sessions_surface.go:handleNavigationKey, and skills.go:navigationMove repeat the six key-to-move mappings. Some filtered surfaces, notably Models, deliberately use raw menu arrows instead of general Up/Down; those are not interchangeable.
  • Contributor boundaries: docs/tui.md Layout and navigation; root AGENTS.md and test-isolation rules; surface_arch_test.go explicitly governs surface homes and Model-owned state regressions.

Proposed contracts

Shared navigation, not a shared controller

Introduce a small UI-package helper for pure translation from tea.KeyPressMsg plus the caller's keyMap to (bounded.Move, matched). Map Up/Down, ScrollU/ScrollD, ScrollTop/ScrollBottom in that order, respecting remaps. Unmatched keys stay unmatched. No literal additional chords, global/default keymap, theme, geometry, selection, activation, or input consumption in this helper. Keep Tea/key dependencies out of internal/bounded.

Use it in Effort and replace the equivalent switches in Memory and the normal Sessions inventory. Preserve caller ordering: Close, tab/filter/action eligibility, compact/loading guards and focus policies remain local. Memory's pending-detail cancellation/generation logic still runs when navigation matches. Sessions' non-inventory paths remain untouched. Update the symbol-home guard if userModelMove is removed rather than leave a redundant wrapper/source of truth.

A similarly small UI wheel-to-line-move helper may be shared between Effort and Memory, since both already/now ignore nonvertical wheel directions; it only translates explicit wheel Up/Down. Do not change other wheel callers' semantics as collateral work. No mandatory broad call-site sweep or generic list/detail abstraction.

Effort ownership and root intent

Allocate the picker as a pointer-owned surface installed in m.modal; remove the separate Model effort field/view predicate and legacy render/key routes. The surface owns list, transient selected tier, compact/usable geometry state, captured presentation inputs, and one-shot intent. Capture effective effort/current marker and known no-reasoning warning at open alongside surfaceDeps. No live catalog refresh mechanism or picker RPC is needed.

On a usable Enter, emit the selected effort value through a narrow intent. Root constructs the existing effortSelection, tears down the modal before entering the existing switchEffort flow, and stops common surface dispatch after the effect takes over. Preserve current Enter focus semantics during connecting; Escape uses common modal teardown/refocus. Do not add a concrete Effort type assertion to generic dispatch. Do not move handoff tokens, persistence, session binding, feed ownership, or recovery into the surface.

The six item IDs are their tier labels; display text excludes cursor/current marker padding. Current status is StatusCells[0] = "●" for the server-resolved tier, independent of cursor selection. Preserve unknown-current fallback to selecting auto without inventing a current marker on a different value.

Geometry and interaction

Parent owns card framing/centering and clamps outer width to the offered terminal width. The 128-cell limit is a ceiling, not a target: derive Effort's preferred outer width from all six complete row labels plus cursor/status gutter, title, captured hints, optional warning, and the actual frame. Do not measure just the visible rows. Keep outer width and height stable during keyboard/wheel browsing at a fixed offer, while adapting to terminal resize. This follows the general content-sizing guidance in docs/tui.md; it is not an Effort-only exception. Surface Render measures the offered content width/height each time, including wrapped title/warning/hints/legend, before allocating list rows. Fit every physical row to offered width. Reserve overflow via the existing list view with indicators; do not subtract indicators twice or hand-roll cursor windows. Standard row styles are spinner for selected and muted otherwise, via presentListRow.

Honor List.indicatorFallback's capacity-one contract: the returned row can coexist with nonzero overflow counts without reserved indicator lines. When exactly one list row fits, put a width-fitted overflow summary on an already-budgeted title/header physical row, never add a new line or wrap that summary. Keep the sole list row available for the visible tier, not an indicator. At larger capacities render only the indicator rows represented by the returned view and budget. Do not copy Memory's unconditional indicator-line appending into this picker or change the bounded library.

At short but usable sizes, show a bounded subset including overflow and reveal the cursor on opening/navigation. Preserve manual wheel window position on ordinary renders; keyboard navigation re-reveals selection. On resize, follow existing bounded geometry/anchor behavior and ensure keyboard navigation reveals selection at the new offer.

If full measured chrome plus a valid list row cannot fit, use the established unframed, width-clipped close-only compact fallback. On zero offer return no body/regions and invalidate usable geometry. At compact/zero geometry consume non-close keys/wheel without navigation or activation, especially Enter after a previously usable offer. Close remains available even when it cannot be displayed. Parent prepares Render before input, so resize-before-next-View cannot use stale geometry.

Use configured Up/Down and page/top/end bindings; all other nonaction keys are swallowed. Vertical wheel scrolls only the list window, never selects/applies or scrolls the hidden conversation; horizontal wheel is inert. No click regions in this slice. Visible hints use captured key markings and only available actions, not hard-coded default chords. List selection may remain outside the manually wheeled window; Enter still applies that selected tier when the layout is usable, consistent with selection-versus-scroll separation.

Observable acceptance

  • Opening via F7 or slash command is idle/capability-gated, blurs the prompt, selects the resolved tier (including max on short screens), and performs no picker RPC. Unknown/unset tier fallback remains existing behavior.
  • Normal, narrow, warning/no-warning, short, and zero offers produce content/frame within parent bounds. Cursor and current markers remain distinct when selection moves. Overflow plus chrome do not crowd out the selected row or exceed offered height. Include exact-one-row budgets with auto, a middle tier, and max selected: height stays bounded, the tier remains visible after reveal, overflow uses existing header space, wheel scroll remains selection-neutral, keyboard re-reveals, and Enter applies the selected tier.
  • On wide terminals the picker takes only its preferred content-sized width; complete auto labels, chrome, warnings, and captured hints fit without requiring the full 128-cell ceiling. Actual outer width/height stay fixed through endpoint/page/line navigation and changing wheel windows at capacities one through six and roomy offers. Long remapped hints respect the ceiling; narrower resize remains bounded. The contributor rule applies to finite pickers generally, not an exception named for Effort.
  • Up/Down clamp at endpoints; page/top/end and remapped bindings select/reveal correctly. Wheel preserves selected tier and hidden conversation position, preserves its window through another render, and keyboard navigation brings selection back. Horizontal wheel and unrelated keys are inert. Helpers preserve Memory/Sessions remaps, guard precedence, filter/tab behavior, and pending-detail cancellation.
  • Resize to compact/zero before any new View prevents Enter from forking; Escape still closes/refocuses; resize back restores a usable picker. Hints reflect remaps and compact actions. Test through Model preparation/dispatch, not only direct surface calls.
  • Enter emits one selected-tier effect, removes the modal before handoff, maps auto to empty, preserves provider/model and source transcript, and remains direct/no-confirm. Actual handoff focus/connecting behavior, source-close ordering, fork/hydration failure recovery, stale-success cleanup and stale-failure inertness retain existing coverage.
  • Architecture gates prevent Model from regaining effort open-lifetime state; generic routing remains concrete-Effort-free. Reopening creates fresh picker state and no late handoff result is treated as surface-owned work.

Implementation tasks

  1. Scenario-first tests and shared navigation. Add failing Effort scenarios at real Model seams; cover the shared helper with remaps/unmatched keys and integrate its equivalent Memory/Sessions callers without changing their guards. Likely new UI navigation helper/test files, usermodel.go, sessions_surface.go, architecture symbol guard. Complete when compatible caller regression tests pass and new geometry/surface scenarios expose the current Effort deficiencies. Run focused UI helper/Memory/Sessions tests.
  2. Atomic Effort ownership + root routing migration (depends on 1). Convert effort.go to a surface and narrow intent, remove Model field/legacy predicates and rendering/key routing together, install through existing open path, apply intent using existing root selection/handoff. Update surface_arch_test.go deliberately, not broad exclusions. Migrate old effort test setup away from private legacy fields/handlers to Model paths. Complete when open/close, input ownership, chosen identity, no-confirm handoff and recovery tests pass; no parallel legacy path remains.
  3. Measured bounded rendering and standard navigation (depends on 2; integrate with it before full gates). Use stable tiers/List/status metadata/shared presenter, fresh physical-row budget and indicators, preferred content-sized width under the 128-cell ceiling, stable browsing dimensions, shared key translation, wheel-only window scroll, and geometry-gated activation. Cover compact/zero offers and resize-before-View. Complete when all new acceptance scenarios pass and normal rendering preserves the tier/warning/legend meaning. Reuse existing clipping/wrapping facilities; no new dependency or custom scroll engine.
  4. Docs and integrated verification (depends on 1–3). Use tech-writer for user-doc edits. Keep only non-obvious wheel/selection behavior in user-docs/mecatui/keybindings.md; do not add an Effort walkthrough or repeat navigation and compact-view hints already provided by the UI. Update docs/tui.md to document the reusable UI navigation translation seam and general content-sized card rules, not migration status. Standing authoring-policy and scoped-instruction/site-exclusion changes belong to separate PR docs: make user-doc authoring guidance directory-scoped #2267, not this implementation slice. Run gates below, review integrated change, and report any remaining tracker scope separately.

Verification and delivery

Focused commands (do not use an end-anchored test regex that silently excludes named subcases):

go test ./cmd/mecatui/ui -run 'Test(Effort|MecatuiEffort|Surface|Modal|UserModel|MecatuiSessionsBoundedList)' -count=1
go test ./cmd/mecatui/ui/internal/bounded -count=1
go test ./cmd/mecatui/ui -count=1

Include new helper/geometry tests explicitly if their names fall outside that regex. Use existing UI fakes; keep tests offline and explicit test-owned storage/config where composition is exercised. Keep effort_test.go, effort_e2e_test.go, effort_handoff_recovery_test.go, keymark, prompt-input, double-Escape, selection, modal and surface-architecture coverage. Run the Memory/Sessions tests for the narrow extraction, not just helper units. No golden updates unless intentional rendering changes require them.

Integrating agent owns one task test for the integrated set, task docs for Markdown changes, and before PR readiness task lint, task test:race, and go run ./cmd/mecademo; allow 600 seconds for full gates and verify demo tool call, permission ask/approval, and result. No contracts/generated configuration change is planned; do not edit generated files manually.

Run initial implementation panel-review against the implementation branch's recorded start commit captured when plan-implement creates the branch, not moving main. No future OID is invented here. Fixes get targeted incremental review against the last reviewed candidate; rebasing requires a separate explicit user request and reassessment of review scope.

When PR creation is separately authorized, link #2170 and #2237 and report bounded progress to #1742 without closing the broader trackers. Preserve a full publishable plan in one identifiable PR conversation comment following plan-implement's archival procedure; verify identity/privacy/conflict/completeness/readback and record comment URL/ID in ignored run metadata, not in the copied plan. Before PR-ready handoff report whether it matches the latest plan. Planning creates no comment/PR and grants no push/merge/monitoring authority.

Decisions, risks, and review

No unresolved user-facing decision at draft time: the user confirmed standard navigation and consistency/reuse. Shared helper extraction is bounded to genuinely equivalent mappings; private signatures/file names need no human decision. Keybinding overlap precedence, wrapped warning geometry, indicator reservation, and intent/close ordering are the main implementation risks; their production-seam tests are required above. Captured warning/current inputs deliberately do not refresh while the surface is open.

Plan-review completed with a fresh-context read-only critic. One important geometry clarification was found and corrected: capacity-one overflow belongs in existing header space, not additional indicator rows. The same reviewer rechecked the amendment and found no remaining concrete correctness gaps. No unresolved blockers or human decisions remain. Reviewer used the supplied inline design because ignored scratch files were unavailable in its checkout; source boundaries were inspected, but implementation/tests were not run by the reviewer. Favorable document review is not runtime verification or permission to implement.

Trim Effort navigation prose already explained by UI hints and retain only the non-obvious wheel selection behavior. Keep authoring rules in user-docs/_README.md, discoverable through the root agent instructions.

Co-authored-by: Mecatl <[email protected]>
Keep the Effort user-documentation trimming here; move standing authoring instructions into a separate PR based on main.

Co-authored-by: Mecatl <[email protected]>
Measure the effort picker using every tier and fixed chrome, keep its dimensions stable during browsing, and document card width limits as ceilings rather than target sizes.

Co-authored-by: Mecatl <[email protected]>
@jbeda
jbeda merged commit ccfd074 into main Oct 11, 2026
62 of 64 checks passed
@jbeda
jbeda deleted the impl/2170-effort-surface branch October 11, 2026 22:58
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 13, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mecatui: bound /effort picker at constrained terminal heights

1 participant