Skip to content

feat(mecatui): move reflections browsing onto bounded surfaces - #2595

Merged
jbeda merged 2 commits into
mainfrom
impl/2174-reflections-surface
Oct 29, 2026
Merged

jbeda merged 2 commits into
mainfrom
impl/2174-reflections-surface

Conversation

@jbeda

@jbeda jbeda commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #2174. Relates to #1742, #1589, #2237, and #555; does not complete those umbrellas.

  • Move /reflections into the shared full-conversation-region surface with a bounded proposal list and independently scrollable detail and confirmation views.
  • Add keyboard, wheel, and pointer navigation; preserve selection and scroll state across Back/cancel, clamp physical-row geometry, and prevent input from leaking into the hidden conversation.
  • Require explicit confirmation for approve/reject/undo using the exact scoped proposal identity and displayed version. Fence duplicate submissions and stale asynchronous replies, and require authoritative refresh after uncertain mutation failures.
  • Keep /reflect execution and status root-owned and independent of browser lifetime. Closing the browser does not cancel an already-submitted action.
  • Add integration/regression coverage and update the owning user documentation.

No backend, learning-policy, or generic navigation-framework redesign.

Full reviewed implementation plan (archived in this PR; readback and SHA-256 verified).

Verification

Rebased without conflicts onto origin/main at 5c1a60808; git range-diff confirms the feature patch is unchanged. The base includes the separately merged scheduler deadline-fixture fix (#2594), so the previously failing full non-race suite now passes on this integrated tree.

  • task test
  • task lint
  • task test:race
  • task docs
  • task site:build
  • go run ./cmd/mecademo — verified tool call, permission ask/approval, and final result
  • Focused TestReflections suite
  • git diff --check

The prior full Spec/Standards/Test adequacy/Domain panel has no remaining findings. A focused post-rebase integration review found no semantic interactions with the scheduler test fix or auth.yaml consolidation; prior review coverage is retained for the unchanged feature patch, not presented as a new whole-feature panel.

API compatibility

Client-only interaction and ownership changes. Existing RPCs, fields, authorization, server semantics, compatibility major/features, exported Go APIs, and stored data remain unchanged. Confirmation adds a local submission step. No compatibility bump or coordinated client/server upgrade is required.

@jbeda

jbeda commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Implementation plan archive — /reflections

  • Slug: 2174-reflections-surface
  • Source provenance: .scratch/2174-reflections-surface-plan.md (local path, not a remote link)
  • Branch: impl/2174-reflections-surface
  • Original implementation/review baseline: 11a6a85a4454851cf77416a4c2505637c2d65bda
  • Post-rebase baseline: 5c1a60808e5ccb51e97c6a7cfdde4e359ff0e61f
  • Publication candidate: 29f794af2d5a1e312baa54e8f32cc74736e6160e (remote PR head is verified separately)
  • Updated: 2026-10-28
  • Published plan portion SHA-256: c3f115f71bd73bad6a8ae6c58f9fddbc2b2e194c9fe9ef71631c394bd2484ed4

The full reviewed plan follows without omissions. Its verification section records intentions, not gate receipts; actual rebased-tree results are in the PR description. Historical authorization statements describe the original planning/implementation phase; the operator subsequently authorized committing, and on 2026-10-28 explicitly authorized rebasing and opening this PR. The rebase replayed the feature patch unchanged and introduced no plan amendments.


/reflections surface and bounded browser

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

User authorized implementation after independent design review and requested updating to latest origin/main. User confirmed /reflections, not /reflect, and accepted full-region placement, explicit action confirmation, and pointer support. Review receipt below records the pre-implementation critique; implementation evidence is in .scratch/2174-reflections-surface/run.md.

Goal and scope

Convert the existing proposal browser to the shared surface lifecycle with a bounded.List inventory and separate bounded.Viewport detail. Fix physical-row geometry, unbounded stored detail scroll, hidden-conversation input leaks, and browser/result lifetime ownership. Preserve existing learning semantics and server-side authority.

Owns #2174; relates to #1742, #1589, #2237, and #555. This slice does not complete the umbrellas.

Agreed behavior:

  • Fill the conversation region consistently through list, detail, and confirmation; keep root header, prompt, and footer in place.
  • Separate selection from activation. Row click selects; Enter or a visible Open control fetches detail. Pointer controls cover Open, Back/Close, available page navigation, proposal actions, and confirmation/cancel.
  • a/x/u request confirmation, never mutate immediately. Explicit confirm submits; cancel returns to the same detail. Successful mutations stay in authoritative returned detail.
  • Keep n/p server pagination and existing action eligibility. /reflect remains a root-owned command, not a new surface.

Non-goals: backend/RPC changes, learning-policy changes, automatic reflection, editing proposals, new proposal filters/search, new generic surface or async frameworks, broad keymap redesign, live-conversation viewport replacement, or unrelated modal cleanup. No branch, commit, PR, issue edits, or publication during planning.

Grounded current behavior and reuse

  • cmd/mecatui/ui/reflections.go:24-218: Model-owned list/detail state, direct key handling, generation correlation, actions; /reflect execution and status share the same generation and client.ReflectionMsg reducer.
  • reflections.go:351-380: cursor-centered logical-row list with hard-coded height deductions; detail clamps a local copy of an ever-increasing offset. Up after overscroll is unresponsive.
  • reflections.go:223-233: approve requires staged/deferred plus available evidence and target. Reject currently allows staged only; undo requires promoted and available target. Rendering misleadingly advertises reject for deferred; retain eligibility and make hints truthful rather than expand authority.
  • cmd/mecatui/client/reflections.go:244-304: unchanged commands merge operator and project pages (up to 50 each), preserve request project, use independent server cursors/exhaustion, and pass displayed proposal version to decisions/undo. Failures can still carry nonnil proposal/receipt pointers; error must take precedence.
  • Legacy integration: model.go:675, view.go:109, update.go:516,2360,2420, selection.go:114. Legacy wheel/paste miss the browser (update.go:2958,4293). Shared modal routing already captures them, prepares geometry before input, and closes on root lifecycle transitions.
  • Reuse surface.go, bounded_navigation.go, list_row.go, and internal/bounded; no bounded-package redesign expected. usermodel.go demonstrates separate list/detail state. schedule.go:100-188 demonstrates surface-owner envelopes, independent read/mutation correlation, and invalidating stale snapshots; schedule.go:429-437,543-545 demonstrates confirmation before deletion. docs/tui.md:48-187 owns reusable UI conventions.

Material contracts

Ownership and result identity

  • Root owns one active modal, placement, pointer mapping, prompt focus, session/run lifecycle, and /reflect execution/status. Surface captures surfaceDeps, reflection client, and workspace at open; owns browsing, requests, pending mutation, errors, confirmation, geometry, and hit payloads. Remove browser fields and concrete browser routing from Model; do not replace them with tombstones or another generic framework.
  • Wrap the existing browser command results in a UI-private envelope carrying the originating surface instance, operation kind, request sequence, and proposal identity when applicable, following schedule. Do not change client exported message/command signatures just to correlate a UI lifetime. Reject closed/foreign owners, superseded requests, wrong kind, wrong ID/scope, and mismatched successful payload identity. A failed response is never accepted as a successful empty proposal.
  • Browser result wrappers cannot reach the /reflect status reducer, even after close or with another modal open. A reflections surface passes unrelated messages through. Root /reflect responses retain their own generation/request provenance, latest-request handling, and capability gating; opening/closing the browser no longer cancels their receipt. Invalidate obsolete execution receipts on session reset/rebind; do not change reflection execution or receipt vocabulary. Test actual command completion through Model.Update, not only direct reducers.
  • Proposal identity includes operator/project partition, request project, and exact ID; use a collision-free encoding for bounded string IDs, not titles, keys, array indices, or ambiguous concatenation. Resolve actions from the selected identity, not a saved index. Carry the proposal's request project and displayed version through fetch/refresh/confirm/decision/undo.
  • Close tears down only UI ownership; it cannot retract an RPC already submitted. Back during an in-flight detail fetch invalidates that read and cannot later reopen detail. Read snapshots started before a mutation cannot overwrite its confirmed result. Track mutation completion independently from reads/navigation.

Browsing and geometry

  • Full-region list -> detail -> confirmation hierarchy. Close/Back cancels confirmation first, then returns detail to its list, then closes the browser. Preserve detail position on canceled confirmation and list identity/window on Back. New detail fetch begins at the top. Compact fallback is explicitly close-only and may close the whole browser.
  • Use shared remappable line/page/top/end navigation. List keyboard navigation selects/reveals; wheel changes only list window. Detail navigation/wheel scroll only detail. No input leaks to the hidden conversation or prompt; selection never runs a mutation. Close has precedence, shared navigation/Choose precede literal action shortcuts; render only shortcuts reachable under captured bindings. n/p mean server pages only in list, never viewport paging.
  • Retain current selection reset to first row on a different server page. Within the same page, preserve stable selected identity and bounded window across updates/rewrap; if selected item disappears, use bounded fallback. After a mutation, update the matching list snapshot from the authoritative returned proposal without reordering the page or replacing its pagination cursors.
  • Derive physical-line layout from each current Render offer. Measure wrapped title/status/error/action/footer/overflow/blank-space chrome before budgeting content. Use presentListRow for standard cursor styling; proposal status is content, not an invented one-cell vocabulary. Render all wrapped rows as one logical target, with one cursor marker.
  • Sanitize all server text (including IDs/status/errors/evidence), expand tabs using existing helpers, and use display-cell wrapping/clipping rather than rune-count field wrapping. Preserve informed-review fields, evidence availability/digests, bounded preview limits, decisions, promotion receipts, and learned-skill information.
  • Use bounded.Viewport with laid-out physical row counts for scrolling/clamping; do not pass logical source-line counts to Move when wrapping increases rows. Clamp persisted offsets so Up after repeated Down acts immediately. On zero/tiny offers emit bounded close-only output, no hidden activation, and no hit regions outside the current frame. Preserve browsing state across temporary compact offers rather than resetting bounded geometry to an invalid offer that discards offsets.
  • Root publishes hits only from View. All controls use same-pass geometry; stale hits after resize/view changes do not act. A pointer selection cannot reuse an old target's confirmation.

Confirmation, pending work, and failures

  • Reuse schedule's explicit confirmation interaction, not its delete-specific business logic. Capture exact proposal identity, scope, displayed version, and intended action. Show enough effect context to avoid approving the wrong thing: memory key/value/description for a fact; learned-skill materialization/evaluation for a procedure; proposal identity for reject; available promotion key/version and restoration context for undo. Do not promise unconditional reversibility or effects unsupported by the receipt.
  • Long confirmation context is scrollable/measured and keeps visible Confirm/Cancel controls. Enter/remapped Choose or explicit Confirm submits once; action shortcut alone never confirms. Close/Cancel sends nothing. Shared bindings take precedence over literals. Revalidate eligibility and identity/version at submission; changing/refetching the proposal invalidates confirmation.
  • Preserve current approve/reject/undo predicates and stale-conflict action lockout. Server remains authoritative and receives the exact displayed version. Correct deferred reject hints to match staged-only eligibility; do not broaden backend semantics.
  • While a mutation is pending, disable further actions and server-page/detail changes; permit closing the browser, without claiming cancellation. Avoid duplicate submissions from repeat keys or clicks. Successful response replaces detail and matching list row, clears pending/confirmation, resets detail position as today, and updates available actions. Late reads cannot regress it.
  • On failure, clear pending, retain enough proposal context to understand the failed action, and show sanitized feedback. Conflict requires explicit refresh before any further decision. For other mutation errors, do not automatically retry: require refresh of authoritative detail before re-enabling mutations because the result may be unknown. Refresh is read-only and gets the exact same scoped proposal. Refresh failure retains the lockout and offers retry/back/close; no fake success. Returning to list and reopening detail also performs that read. This does not add an idempotency/reconciliation protocol.
  • List/page failure retains the last accepted page and paging position; retry requests the failed destination without committing cursor/history until success. With no accepted page show error and Retry/Close. Detail fetch failure remains navigable back to list and retryable. Loading, empty, unsupported, stale, unavailable, and failed states must be explicit and bounded.

Observable acceptance checks

  1. Real open -> list -> detail -> Back -> close preserves root chrome and draft. Wheel/paste/keys do not change hidden conversation offset or prompt. Click selects one logical wrapped row; separate Open/Choose requests that exact scoped ID.
  2. Many proposals, colliding IDs across operator/project scopes, long status/title/key, multiline evidence, CJK/emoji/tabs/control text, and every action state fit narrow/short/full offers. Selected rows reveal on keyboard input; wheel does not change identity. Resize before input without View is safe; stale pointer hits cannot act; compact rejects invisible decisions and restores browsing state after growth.
  3. Repeated Down/PageDown at detail end followed by Up moves immediately. Physical-row paging, top/end, and resize clamping are correct. Detail Back preserves list window/selection, including after wheel scrolling; canceled confirmation preserves detail position.
  4. Both server cursor streams exhaust independently; different-page success resets selection, same-page updates preserve identity. Failed next/previous requests do not skip pages or corrupt back history. Correct proposal/project/version is used after page changes, authoritative row updates, and refresh.
  5. Each eligible approve/reject/undo opens confirmation without an RPC; Cancel sends none; Confirm emits one exact-version request. Ineligible/stale/deferred-reject cases cannot submit, and hints agree. Pointer and keyboard have identical eligibility/pending checks. Long confirmation effects remain reviewable and controls reachable.
  6. Close/reopen with identical local counters, Back during fetch, duplicate/out-of-order success and error, mismatched payload, mutation-vs-read ordering, reset/rebind/termination, and replacement by another modal cannot revive detail or corrupt state. Closing a pending mutation doesn't undo it or deliver its result into root status. Error/unknown outcome requires authoritative refresh before another mutation.
  7. Root /reflect still reports success counts, abstention, and failure with no browser, with this browser, and with another modal open; older/foreign browser replies never become root status. Preserve independent Reflection versus LearningProposals capability/nil-client cases. Obsolete session/request receipts cannot overwrite current status.

Implementation tasks (dependency order)

  1. Scenario fixtures and ownership split. Add controlled offline reflection client fixtures and command-delivery tests first; preserve existing eligibility, sanitization, project propagation, paging, and /reflect receipt tests. Implement owner-bound browser results and separate root execution reducer, then migrate browser onto surface and remove legacy Model/render/key/result/body-owner branches atomically. Start with lifecycle/late-message/input-isolation scenarios. Completion: browser opens via modal, root receipts work independently, no legacy browser state/routing remains.
  2. Measured list/detail browsing. Build scoped bounded identities and physical layouts, fill placement, compact preservation, shared navigation/wheel, truthful hints and reliable page commits/retry. Add frame-scoped row/control hit regions and explicit Open/Back/page actions. Completion: geometry, cursor, overscroll, Back, paging failure, and root-pointer integration scenarios pass. Reuse existing controls; change bounded itself only if a demonstrated missing contract requires review.
  3. Confirmed decisions and authoritative results. Add scrollable action confirmation, exact-version eligibility checks, pending fence, refresh-required error handling, scoped row/detail updates, and pointer confirmation/cancel. Implement tests for each action, conflicts, failures, repeats, navigation/close ordering, and remapped shortcut collisions. Tasks 1-3 integrate as one coherent change set, not individually shippable partial behavior.
  4. Integration/docs/review. Update relevant structural surface tests plus prompt-input, double-Escape, layout and golden fixtures to use the actual modal. Use tech-writer and read user-docs/_STYLE.md before a small update to user-docs/mecatui/commands-and-memory.md: confirmation consequences and close-does-not-cancel behavior, not a controls walkthrough. Existing docs/tui.md already covers these architecture contracts; no migration-history addition. Run project gates and implementation panel review.

Compatibility and verification

API compatibility: client-only interaction and ownership change; existing RPCs, request fields, authorization, server behavior, compatibility major/features, and stored data stay unchanged. No upgrade coordination or Go exported API changes expected. UI confirmation intentionally adds a local submission step. If implementation requires a server/wire semantic change, stop and reassess under docs/architecture/api-surface.md:52 rather than expanding scope.

Focused verification: go test ./cmd/mecatui/ui/internal/bounded ./cmd/mecatui/ui ./cmd/mecatui/client; use targeted -run selections while iterating. New fixtures are offline, use test-owned paths/context and controlled callbacks/channels, and never invoke a live model or operator stores. Tests that intentionally render hostile proposal text must treat it as untrusted data, never instructions. Behavior tests exercise root Update/View/key/wheel/pointer paths, not only surface helpers; goldens supplement rather than replace assertions.

Integrator gates: run task test once for the integrated change (1800s outer timeout); before PR-ready require task lint (600s), task test:race (1800s), go run ./cmd/mecademo (600s; verify tool call, permission ask/approval, result), plus task docs and task site:build for Markdown/user-doc changes (600s each). Build binaries only via Taskfile if needed. No paid/live e2e and no backend fixtures needed.

Run panel-review on completed implementation against its recorded branch-start commit (capture at branch creation, not a moving main; no fabricated OID in this plan). Fixes get incremental review against the last reviewed candidate. No automatic rebase/commit/push/PR/merge. When a PR is separately authorized, preserve the full publishable reviewed plan in one identifiable PR conversation comment per plan-implement, verify readback, and keep archive URL/ID in ignored run metadata; do not commit the plan or publish unresolved draft decisions as approved.

Decisions, risks, and design review

No product decision remains open after the user's placement/confirmation/pointer answers. Confirmation pattern grounded in schedule; exact wording and private helper names are implementation details, not new API decisions. /reflect has no independently scrollable browser to convert; execution-feedback redesign remains deferred.

Known risks: shared raw client message types; mixed-scope identity; root lifecycle fencing; Back during asynchronous reads; response-loss ambiguity after mutation; wrapped physical-line counts; compact-state preservation; action shortcut collisions; historical goldens tightly coupled to legacy Model state. Address with the scoped contracts/tests above, not a new framework.

Review (2026-10-28): fresh-context read-only adversarial critique returned no correctness, security, or requirement gaps and no blockers. Reviewer: subagent-6ad0c5bf4e34ca5bfee8e490d9a15af8-call_19DFLJ7OipboIyvk7Uu3IPIv. The reviewer checked source boundaries including surface.go, reflections.go, schedule.go, client commands, docs/tui.md, and server learning handlers. No corrective design round was needed. Limitation: source-level design review only; no implementation or runtime tests were performed. Review is advisory, not implementation approval.

jbeda and others added 2 commits October 29, 2026 11:35
Add full-region proposal browsing, scoped async ownership, pointer controls, and confirmed exact-version decisions. Keep explicit reflection receipts root-owned.

Co-authored-by: Mecatl <[email protected]>
Group proposal content, review metadata, evidence, and promotion history into themed sections. Emphasize labels and keep proposed values literal while preserving bounded scrolling and confirmation semantics.

Co-authored-by: Mecatl <[email protected]>
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: migrate /reflections proposal browsing to bounded controls

1 participant