Add mutation verbs to the macterm CLI (create, split, run, grid)#140
Closed
thdxg wants to merge 1 commit into
Closed
Add mutation verbs to the macterm CLI (create, split, run, grid)#140thdxg wants to merge 1 commit into
thdxg wants to merge 1 commit into
Conversation
With the control plane in place, this teaches it to actually drive the app: project create/select (idempotent by canonical path, ProjectPath- validated, remote specs rejected until #104), tab new/select/close, pane split/focus/close/run, an equal-cells grid verb (the benchmark workhorse), session kill, and layout apply/save. Semantics worth reviewing: - New panes/tabs take a command via the layout run: path (spawn-time initial_input); pane run types into an EXISTING live shell through a new GhosttyTerminalNSView.sendText — the paste path, guarded so a missing surface is a typed no_surface error, never a silent drop. - Headless callers can't answer dialogs, so close/apply verbs return a typed busy error where the UI would stage a confirmation; --force takes the destructive path deliberately. - Every pane's env now carries MACTERM_SESSION (its restart-stable zmx session name), so macterm run inside a pane self-targets. pane close deliberately ignores that fallback: destroying "whatever pane I'm in" by omission is a footgun. docs/cli.md documents the grammar, targeting rules, wire protocol for non-CLI clients, and the same-user security posture.
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.
Second of three PRs for #107, stacked on #139 (base = its branch; will retarget to
mainonce #139 lands). This makes the control plane actually drive the app; PR 3 wires it into the CI benchmark as a workload generator.Verbs added
project create <path> [--name] [--select]— validated throughProjectPath(remote scp-specs rejected with a clear error until Remote projects over SSH backed by zmx #104 stage 2), idempotent by canonical path so scripted setups can run unconditionally.--selectridesselectProject, so a matching central project file auto-applies on first open — declarative tab spawning for free.project select,tab new [--run CMD],tab select,tab close [--force]pane split [--direction right|down|auto] [--run CMD],pane focus(vianavigateToPane: selects tab, fronts window, restores first responder),pane close [--force],pane run <command…>grid <RxC> [--run CMD]— Zentty-inspired equal-cells grid (≤16), the benchmark workhorse:macterm tab new --run X && macterm grid 2x2 --run Xsession kill,layout apply [--force],layout saveDesign points
--runon tab/split/grid uses the layoutrun:path (spawn-timeinitial_input— zmx runs it only on fresh create);pane runtypes into an existing live shell via a newGhosttyTerminalNSView.sendText(the paste path:ghostty_surface_keywith.textoutside a key event). A missing surface is a typedno_surfaceerror, never a silent drop.requestCloseTab, destructive layout reconciles), the handler returns a typedbusyerror with a--forcehint instead. Force takes the direct path. (Note: ghostty's busy detection tracks child processes — a nushell builtin likesleepdoesn't trip it, same as the UI.)MACTERM_SESSION(merged inensureNSView), so a baremacterm pane splitinside a pane splits itself. Session names are the restart-stable address (pane UUIDs regenerate on relaunch; a reattached zmx shell's env stays correct).pane closedeliberately ignores the env fallback — destroying "whatever pane I'm in" by omission is a footgun; it demands--pane/--session.SplitNode.splitting(command:),TerminalTab.split(command:)/makeGrid,Workspace.createTab(command:), plus pane-targetedAppState.splitPane(_:direction:projectID:command:)andmakeGrid.makeGridrebalances to equal cells regardless of the auto-tiling pref (a grid is an explicit request for uniformity).docs/cli.mddocuments the grammar, targeting precedence, the wire protocol for non-CLI clients, and the security posture (same-user filesystem perms; no token auth by design, envelope leaves room).Testing
mise run format/lint/testgreen. New coverage: handler mutation tests (create/select/new/close/split/focus/run/grid/kill/apply/save incl. all error codes) against realAppState+ tempdir stores;TerminalTab.makeGridand command-threading model tests; layout save→apply round-trip against a tempdirProjectFileStore.$HOME+MACTERM_BENCHMARK_DATA_DIR):project create --select→tab new --run→pane split→grid 2x2 --run(5-pane tab),pane runinto a background tab, busy-close correctly refuses on a running/bin/sleepand--forcecloses,layout savewrites~/.config/macterm/projects/e2e.yamland a now-destructiveapplyreturnsbusy,session killworks, andps ewwon a pane's shell showsMACTERM_SESSION+MACTERM_SOCKETinjected.