Repository navigation
feat(sesh): let a session pick its own layout profile - #1584
Merged
Merged
Conversation
RED for the per-session layout work. Two cases, both failing now: - a session naming a layout profile emits its own startup_command while a session that names none stays bare and inherits [default_session] - a session naming a profile that does not exist fails at eval, with a message carrying the offending name and the valid ones The ci profiles declare no sessions, so `_ci_full_config` cannot express per-session behaviour; these render sesh.toml from a synthetic home config instead. That needs expression eval rather than an installable, so nix_helpers grows `nix_eval_expr` — returning the completed process rather than asserting, so the guard's failure path is testable at all. It also gives the previously unused `flake_expr` its first caller. Current failures are the intended ones: the first reports that `vigos.sesh.layout.profiles` does not exist, the second gets an option-does-not-exist error naming neither the bad profile nor the valid set. Refs: #1583
GREEN for the tests committed in 349f058. `layout.windows` chose which windows a session got, but globally: every seed opened identically, so a repo with no pull-request workflow still started a dashboard window on a permanently empty view. Disabling the module and hand-writing sesh.toml was the only way out — discarding the layout mechanism entirely to change one window. Add `layout.profiles` (named window sets) and a `layout` field on a session that selects one. `default` stays `layout.windows` and wins over a same-named profile key, so the default set has one home rather than two that can disagree. Delivery is sesh's own config, not a new mechanism: SessionConfig embeds DefaultSessionConfig, so a `[[session]]` already accepts startup_command, and startup.Exec resolves per-session ahead of [default_session]. A session with a profile emits `startup_command = "sesh-layout <profile>"`; one without stays bare and inherits. sesh-layout gains the profile as an argument and stays a single binary, because consumers probe for it by name to detect a provisioned host. The layout body is factored into renderProfile so one code path serves every profile including the default. An undefined profile throws while rendering rather than via `assertions`, which never fire when only the sesh.toml option is evaluated; the message names the session, the bad profile and the valid set. Backward compatible: with profiles empty and no session setting layout, the generated sesh.toml and script are unchanged. Verified beyond the unit tests, against a built script from a synthetic config: `default` yields edit/git/shell/claude and `docs` yields edit/shell, re-running inside a live session leaves windows untouched and exits 0, and an unknown profile prints to stderr and exits 1. Refs: #1583
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.
Description
vigos.seshapplied one window set to every project.layout.windowsparameterizes which windows a session gets, but the choice is global — every seed insessionsopened identically, so a repo with no pull-request workflow still started a dashboard window on a permanently empty view, and a docs repo still got a git TUI it had no use for. The only escape was disabling the module and hand-writingsesh.toml, discarding the whole layout mechanism to change one window.This adds named layout profiles and a per-session selector. Opt-in and backward compatible.
Type of Change
feat-- New featurefix-- Bug fixdocs-- Documentation onlychore-- Maintenance task (deps, config, etc.)refactor-- Code restructuring (no behavior change)test-- Adding or updating testsci-- CI/CD pipeline changesbuild-- Build system or dependency changesrevert-- Reverts a previous commitstyle-- Code style (formatting, whitespace)Modifiers
!) -- This change breaks backward compatibilityChanges Made
nix/home/sesh.nixvigos.sesh.layout.profiles— attrset of named window sets, reusing the existingwindowModule. Empty by default.sessions[].layout—nullOr strnaming a profile. Null (default) inherits.defaultislayout.windowsand wins over a same-named key inprofiles, so the default set has one home rather than two that can disagree.renderProfileso one code path serves every profile including the default;sesh-layoutdispatches on an optional argument and stays a single binary, because consumers probe for it by name to detect a provisioned host.Why the guard throws rather than using
assertions: assertions only fire when the activation package is evaluated. A consumer (or a test) that evaluates justhome.file.".config/sesh/sesh.toml".textwould sail past them and emit asesh.tomlwhose sessions all die atsesh connect— far from the definition that caused it.Delivery uses sesh's own config, not a new mechanism.
SessionConfigembedsDefaultSessionConfigin sesh'smodel/config.go, so a[[session]]block already acceptsstartup_command, andstartup.Execresolves per-session → wildcard → default. A session with a profile emitsstartup_command = "sesh-layout <profile>"; one without stays bare and inherits[default_session].Rejected alternatives (detail in #1583): sesh's native
[[window]]+ per-sessionwindows— it sends startup keys to the session rather than a captured#{window_id}(this module captures ids precisely because names collide or auto-rename), errors if a name has no[[window]]block, and cannot run a command in window 1 with a shell fallback, which is how the first entry works.[[wildcard]]patterns never fire for curated seeds, becauseconfigWildcardStrategyneeds the connect name to resolve to a directory. Inlinesessions[].windowsduplicates a window list across every session sharing a layout.Changelog Entry
Testing
just test) — see the note below; not run as-isTDD, commits in order:
349f0581adds the RED tests,5e4714admakes them GREEN._ci_full_configcannot express per-session behaviour (the ci profiles declare no sessions), so the new tests rendersesh.tomlfrom a synthetic home config. That needs expression eval rather than an installable, sotests/nix_helpers.pygrowsnix_eval_expr— returning the completed process rather than asserting, which is what makes the guard's failure path testable at all. It also gives the previously unusedflake_exprits first caller.What I actually ran, and what I did not.
just testwas not run as written: it chainstest-image/test-integration, which build and run the dev container image — unrelated to a Nix-module change and expensive. Instead:uv run pytest tests/ --ignore=tests/test_image.py --ignore=tests/test_integration.py --deselect …::test_flake_check_succeeds→ 935 passed, 1 skipped (192s).test_flake_check_succeedsis deselected in CI too, where nix-fast-build builds the same checks.prek run --all-files→ fully green, and the tree was still clean afterwards (no hook rewrote anything).The container lanes are left to CI.
Manual Testing Details
Built the generated
sesh-layoutfrom a synthetic config declaring adocsprofile, and exercised the real artifact in scratch tmux sessions rather than reading the source:defaultprofileedit git shell claude— unchanged from module defaultsdocsprofileedit shellsesh-layout: unknown profile nopeon stderr, exit 1startup_command = "sesh-layout docs"; silent session stays bareScratch sessions were killed afterwards.
The mechanism was also field-proven in a consumer config before being upstreamed here — the same path
vigos.seshitself took ("parameterized port of the maintainer's proven setup") — including a check that the generatedsesh.tomlparses under sesh 2.26.2 with every seed still listed.Checklist
docs/templates/, then runjust docs) — no template change needed; the option descriptions carry it, andgenerate-docsis greenCHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Additional Notes
The
assets/workspace/.devcontainer/CHANGELOG.mdhunk is thesync-manifesthook mirroring the root changelog into the scaffold template — generated, not hand-edited.Reviewer's shortest path to the risk: the default profile must be byte-for-byte the old behaviour.
renderProfileis the old body withcfg.layout.windowsreplaced by its parameter, andlayoutProfilesbindsdefaulttocfg.layout.windows, so an unconfigured consumer gets the same script modulo thecasewrapper.Refs: #1583