Skip to content

feat(sesh): let a session pick its own layout profile - #1584

Merged
c-vigo merged 2 commits into
devfrom
feature/1583-sesh-layout-profiles
Aug 31, 2026
Merged

c-vigo merged 2 commits into
devfrom
feature/1583-sesh-layout-profiles

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

vigos.sesh applied one window set to every project. layout.windows parameterizes which windows a session gets, but the choice is global — every seed in sessions opened 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-writing sesh.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 feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

nix/home/sesh.nix

  • vigos.sesh.layout.profiles — attrset of named window sets, reusing the existing windowModule. Empty by default.
  • sessions[].layout — nullOr str naming a profile. Null (default) inherits.
  • default is layout.windows and wins over a same-named key in profiles, so the default set has one home rather than two that can disagree.
  • The layout body is factored into renderProfile so one code path serves every profile including the default; sesh-layout dispatches on an optional argument and stays a single binary, because consumers probe for it by name to detect a provisioned host.
  • An undefined profile throws while rendering, naming the session, the bad profile and the valid set.

Why the guard throws rather than using assertions: assertions only fire when the activation package is evaluated. A consumer (or a test) that evaluates just home.file.".config/sesh/sesh.toml".text would sail past them and emit a sesh.toml whose sessions all die at sesh connect — far from the definition that caused it.

Delivery uses sesh's own config, not a new mechanism. SessionConfig embeds DefaultSessionConfig in sesh's model/config.go, so a [[session]] block already accepts startup_command, and startup.Exec resolves per-session → wildcard → default. A session with a profile emits startup_command = "sesh-layout <profile>"; one without stays bare and inherits [default_session].

Rejected alternatives (detail in #1583): sesh's native [[window]] + per-session windows — 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, because configWildcardStrategy needs the connect name to resolve to a directory. Inline sessions[].windows duplicates a window list across every session sharing a layout.

Changelog Entry

### Added

- **A `vigos.sesh` project can now open with its own window layout**
  ([#1583](https://github.com/vig-os/devkit/issues/1583))
  - `layout.windows` chose *which* windows a session got, but the choice was
    global: every seed in `sessions` opened 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-writing `sesh.toml`, discarding the
    whole layout mechanism to change one window
  - `vigos.sesh.layout.profiles` takes named window sets and a session's new
    `layout` field selects one; `default` remains `layout.windows` and cannot be
    redefined, so there is one home for the default set rather than two that can
    disagree
  - Delivery is sesh's own config rather than a new mechanism: a session with a
    profile emits `startup_command = "sesh-layout <profile>"`, which sesh
    resolves ahead of `[default_session]`, so a session naming no profile stays
    bare and inherits the default. `sesh-layout` takes the profile as an
    argument and stays a single binary — consumers probe for it by name to
    detect a provisioned host
  - A session naming an undefined profile fails at eval, listing the valid
    names, rather than producing a `sesh.toml` whose sessions die at connect
    time far from the definition that caused it
  - Backward compatible: with `profiles` empty and no session setting `layout`,
    the generated `sesh.toml` and layout script are unchanged

Testing

  • Tests pass locally (just test) — see the note below; not run as-is
  • Manual testing performed (describe below)

TDD, commits in order: 349f0581 adds the RED tests, 5e4714ad makes them GREEN.

_ci_full_config cannot express per-session behaviour (the ci profiles declare no sessions), so the new tests render sesh.toml from a synthetic home config. That needs expression eval rather than an installable, so tests/nix_helpers.py grows nix_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 unused flake_expr its first caller.

What I actually ran, and what I did not. just test was not run as written: it chains test-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_succeeds is 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-layout from a synthetic config declaring a docs profile, and exercised the real artifact in scratch tmux sessions rather than reading the source:

Check Result
default profile edit git shell claude — unchanged from module defaults
docs profile edit shell
Idempotency guard (re-run inside a live session) window set untouched, exit 0
Unknown profile sesh-layout: unknown profile nope on stderr, exit 1
Per-session emission selecting session gets startup_command = "sesh-layout docs"; silent session stays bare

Scratch sessions were killed afterwards.

The mechanism was also field-proven in a consumer config before being upstreamed here — the same path vigos.sesh itself took ("parameterized port of the maintainer's proven setup") — including a check that the generated sesh.toml parses under sesh 2.26.2 with every seed still listed.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs) — no template change needed; the option descriptions carry it, and generate-docs is green
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

The assets/workspace/.devcontainer/CHANGELOG.md hunk is the sync-manifest hook 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. renderProfile is the old body with cfg.layout.windows replaced by its parameter, and layoutProfiles binds default to cfg.layout.windows, so an unconfigured consumer gets the same script modulo the case wrapper.

Refs: #1583

c-vigo added 2 commits August 31, 2026 10:57
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
@c-vigo
c-vigo merged commit 9885184 into dev Aug 31, 2026
14 checks passed
@c-vigo
c-vigo deleted the feature/1583-sesh-layout-profiles branch August 31, 2026 09:18
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