Skip to content

refactor(mecatui): surface interface + soul proof-of-pattern (#555 Phase 2) - #644

Merged
jbeda merged 1 commit into
mainfrom
surface-soul-migration
Aug 25, 2026
Merged

jbeda merged 1 commit into
mainfrom
surface-soul-migration

Conversation

@jbeda

@jbeda jbeda commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What

Introduce the surface interface so a modal/overlay owns its render, input, and teardown in one file, and migrate the /soul overlay onto it as the first surface. Issue #555 Phase 2 — the proof-of-pattern migrator.

Final interface

type surface interface {
    Render(width, height int) (body string, regions []ClickableRegion)
    HandleKey(msg tea.KeyPressMsg) (cmd tea.Cmd, handled bool, closed bool)
    HandleMsg(msg tea.Msg) (cmd tea.Cmd, handled bool, closed bool)
    HandleWheel(msg tea.MouseWheelMsg) (cmd tea.Cmd, handled bool)
    Close()  // returns nothing; the parent refocuses
}

Design

  • One modal surface. The Model holds ONE modal surface (nil-vs-set). Stack/tiling/focus-tree is Phase 3.
  • Dynamic Open, no tombstone field. The modal state is constructed at Open and lives only in m.modal.
  • Deps held on state. surfaceDeps is the shared ambient base (theme/keys/marks/caps), built once at Open and held as the surface's deps field. Surface-specific collaborators are fields on the surface's own struct. Ambient deps immutable-after-startup (dynamic-settings flow banked, see mecatui: live-reload operator settings (keymap) without restart #456).
  • Geometry is immediate-mode (ImGui). Render(width, height) recomputes every frame from the offered args; there is NO resize event. Geometry-dependent view state (a scroll clamp) is re-derived at the top of Render from the fresh args — the ImGui ImGuiWindow.Scroll model. Retained view-state fields are marked // view cache:.
  • Parents place, surfaces size. The Model centers via centerCard in view.go; the surface MUST NOT call centerCard internally.
  • Render returns body + regions together (measure-once).
  • HandleMsg owns RPC routing (consume/kill/defer); surface state created dynamically at Open.
  • Wheel is default-consume (modal captures input; never falls through to the conversation viewport unless it deliberately delegates).

Verification

task build, task test, task lint, task test:golden (goldens byte-identical), go run ./cmd/mecademo — all green. Panel-reviewed.

Out of scope

Stack, tiling/focus tree, approvalButton component extraction, bubblezone adoption, any approval change, the stale "ADR 0108" citation fix, the dynamic-settings deps-update flow (#456).

Plan: docs/design/surface-migration-plan.md.

jbeda added a commit that referenced this pull request Aug 19, 2026
Five review notes; all gates green (`task build`, `task test`, `task
lint`, `task test:golden`, `go run ./cmd/mecademo`).

- Parents place, surfaces size: `Render` loses its width/height
  parameters; geometry arrives via a `Resize(width, height int)` method
  (the WindowSizeMsg idiom). `soulState` stores the geometry and
  `Render` returns the inner body only; `view.go`'s renderBody arm now
  calls `centerCard` on the returned body — the parent centers.
- Rename `active` → `modal`: narrows the seam honestly; the stack/
  tiling phase layers a stack on `modal` later. The gate (`surface_arch_test`)
  now asserts `TestModelHasOneModalSurfaceField`.
- Move `updateInventoryMsgs` off worktrees.go to mcp.go (bad home, legacy
  fallback chain for unmigrated inventories; soul no longer uses it).
- Generalise the design doc: `surface-migration-soul-plan.md` →
  `surface-migration-plan.md` — soul is the first migrator and the
  checklist covers the remaining six overlays.
- De-churn "soul is the first" mentions in generic dispatch comments.

Co-Authored-By: mecatl <[email protected]>
@jbeda
jbeda marked this pull request as ready for review August 19, 2026 04:01
jbeda added a commit that referenced this pull request Aug 19, 2026
Five review notes; all gates green (`task build`, `task test`, `task
lint`, `task test:golden`, `go run ./cmd/mecademo`).

- Parents place, surfaces size: `Render` loses its width/height
  parameters; geometry arrives via a `Resize(width, height int)` method
  (the WindowSizeMsg idiom). `soulState` stores the geometry and
  `Render` returns the inner body only; `view.go`'s renderBody arm now
  calls `centerCard` on the returned body — the parent centers.
- Rename `active` → `modal`: narrows the seam honestly; the stack/
  tiling phase layers a stack on `modal` later. The gate (`surface_arch_test`)
  now asserts `TestModelHasOneModalSurfaceField`.
- Move `updateInventoryMsgs` off worktrees.go to mcp.go (bad home, legacy
  fallback chain for unmigrated inventories; soul no longer uses it).
- Generalise the design doc: `surface-migration-soul-plan.md` →
  `surface-migration-plan.md` — soul is the first migrator and the
  checklist covers the remaining six overlays.
- De-churn "soul is the first" mentions in generic dispatch comments.

Co-Authored-By: mecatl <[email protected]>
@jbeda
jbeda force-pushed the surface-soul-migration branch from f29f9d8 to 1143803 Compare August 19, 2026 23:16
jbeda added a commit that referenced this pull request Aug 19, 2026
…hase 2)

The second surface migrator, onto the NEW deps-on-state interface (base
PR #644). Multi-view enum (panel/detail), textinput filter, cursor,
scroll window, epochs, four RPC message types.

skillsState implements surface on pointer receivers: Render picks
panel-vs-detail on s.view and re-derives the scroll clamp from the fresh
width at the top (the ImGui clamp-in-Render rule — the width it caches
is a view state, marked `// view cache:`); HandleKey carries the
verbatim router (detail actions a/x/d/v/r + panel enter + two-stage esc
+ bare up/down by msg.String ONLY + pgup/pgdn/home/end + filter-feed
fallthrough); HandleMsg consumes the four RPC types with
requestID/generation staleness; SkillChangesMsg passes to the slim Model
reducer updateSkillChangesMsg. HandleWheel scrolls the panel (NEW
behavior — pre-migration the wheel fell through to the conversation
viewport). Close returns nothing; the parent refocuses.

Domain deps are fields on skillsState: deps (shared base), ctx,
learnedLifecycle (the LearnedSkillClient), nextEpoch (Model-owned
skillsEpoch closure). skillsEpoch STAYS a Model field (correlation
survives close/reopen). The gate: surfaceFileHomes +skills.go (count 3),
TestModelHasNoSkillsStateField, TestSurfaceDepsIsAmbientOnly (rejects
the archived widening). runSkills in skills.go (one-file-owns-it).

Review panel: spec/standards/security/architecture/QA landed fixes —
TestSurfaceDepsIsAmbientOnly, TestSkillsWheelScrollsPanel (consume
contract), TestLearnedMsgsViaUpdate (3 more RPC routing pins),
TestSkillsScrollClampedInRender (ImGui clamp). Goldens byte-identical;
all gates green.

Stacked on PR #644.

Co-Authored-By: mecatl <[email protected]>
@jbeda
jbeda marked this pull request as draft August 20, 2026 18:18
@jbeda
jbeda force-pushed the surface-soul-migration branch from 1143803 to f458f9f Compare August 21, 2026 03:23
@jbeda
jbeda marked this pull request as ready for review August 25, 2026 00:08
@jbeda
jbeda force-pushed the surface-soul-migration branch from f458f9f to 938b656 Compare August 25, 2026 00:08
@jbeda
jbeda merged commit 398c85c into main Aug 25, 2026
18 checks passed
@jbeda
jbeda deleted the surface-soul-migration branch August 25, 2026 00:55
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.

1 participant