Experimental: pure-chain ChainWorkspaceBuilder + --builder=chain#1054
Open
tony wants to merge 3 commits into
Open
Experimental: pure-chain ChainWorkspaceBuilder + --builder=chain#1054tony wants to merge 3 commits into
--builder=chain#1054tony wants to merge 3 commits into
Conversation
why: Build the experimental ChainWorkspaceBuilder against the in-progress
libtmux._experimental.chain API on the sibling libtmux worktree.
what:
- Add [tool.uv.sources] libtmux = { path = "../libtmux", editable = true }
- Relock against the local editable checkout
why: Showcase libtmux's experimental chain API downstream: build a whole workspace's window/pane tree in the minimum tmux invocations instead of one subprocess per new-window / split-window. what: - Add ChainWorkspaceBuilder (subclass of WorkspaceBuilder): one ForwardPlan seeded from the session builds every window and pane, reusing the session's default window as window 1 (no orphan) via initial_window / initial_pane - send_keys_mode: readiness (default, classic per-pane shell-ready delivery) or batched (folded into the plan) - Reuse parent helpers (_wait_for_pane_ready, config_after_window, focus, plugins, before_script, options) - Tests: two/three-pane structure, focus, readiness commands land, batched
why: Make the experimental ChainWorkspaceBuilder selectable from the CLI
without replacing the default builder.
what:
- Add --builder={default,chain} to `tmuxp load` (Env: TMUXP_BUILDER),
threaded through command_load -> load_workspace as builder_name
- Select ChainWorkspaceBuilder when chosen; default builder otherwise
- Test the flag parsing (smoke-verified `tmuxp load --builder=chain`
builds the expected window/pane tree)
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.
Summary
ChainWorkspaceBuilderthat constructs a workspace's entire session β window β pane tree from a singlelibtmux._experimental.chain.ForwardPlan, resolved over the minimum number of tmux invocations instead of one subprocess pernew-window/split-window.--builder=chainflag totmuxp load(Env:TMUXP_BUILDER); the default builder is unchanged._experimental.chainAPI, pinned to a sibling worktree via[tool.uv.sources]. Not for merge β companion to the libtmux experiment.Changes by area
src/tmuxp/workspace/chain_builder.py(new)ChainWorkspaceBuilder, a subclass ofWorkspaceBuilder, overridingbuild(): the session is created, then every window and pane is described in oneForwardPlanseeded from the session and resolved viaServerPlanRunner. Reuses the parent's helpers (_wait_for_pane_ready,config_after_window, focus handling, plugin hooks,before_script, session options).src/tmuxp/cli/load.pyAdds
--builder={default,chain}(EnvTMUXP_BUILDER), threaded throughcommand_loadβload_workspaceasbuilder_name, selecting the builder class. The rest of the load path is unchanged because the subclass mirrors the constructor,.session, and event hooks.pyproject.toml[tool.uv.sources]pinslibtmuxto the sibling../libtmuxworktree so the experimental chain API is importable.Design decisions
ForwardPlan.from_session(session)and addressing window 1 throughseed.initial_window/seed.initial_panebuilds onto the session's default window instead of moving it aside and killing it (the move-to-99 + kill dance the classic builder performs).send_keys_mode, defaultreadiness. The chain batchessplit+send-keyswithout waiting for the new pane's shell prompt.readinessbuilds only the structure via the chain, then sends each pane's commands shell-ready (matching the classic builder, deterministic).batchedfoldssend-keysinto the plan for the fullest "all at once" β faster, but it can race an interactive prompt.ServerPlanRunner/run_resolving) is the right fit.WorkspaceBuilderkeeps.session,find_current_attached_session, theon_*event hooks, and the plugin lifecycle identical, soload.pyneeds only to pick the class.Test plan
mypy) cleantests/workspace/test_chain_builder.pyβ two/three-pane structure, window + pane focus, readiness-mode commands landing, batched mode, and--builderflag parsingtests/workspace/test_builder.pyandtests/cli/test_load.pystill pass (the subclass leaves the default builder untouched)tmuxp load -d --builder=chain tests/fixtures/workspace/builder/two_pane.yamlbuildseditor(2 panes),logging,test, matching the default builderCompanion PR
Depends on the libtmux experimental chain API: tmux-python/libtmux#685.