fix(cli): run --force creates a nested session inside a pty (parity R1 #4) - #112
Merged
Conversation
…#4) Parity drive R1: `pty run --force` from inside a pty session used to treat `--force` as a no-op — it still ran the command directly in-place and created NO session. That contradicted pty's own `run --help` ("Create even from inside another pty session"), attach's/restart's `--force` symmetry, and the pty-rust port. CoS ruling (decision a, 2026-07-21): fix the node CODE so `run --force` bypasses run's nesting guard and creates a real (nested) session, matching the docs + rust. This makes `--force` on `run` behave like `-d` w.r.t. the guard: both now fall through to session creation (`-d` detached/background, `--force` interactive/attached). Changes: - src/cli.ts: add `&& !force` to the `run` nesting guard so `--force` falls through to cmdRun (creates + attaches a nested session). The inner `-a` refuse-when-running sub-check is now reached only in the no-force path, so its redundant `!force` condition is dropped. Comments updated. - tests/parity-node-reference.test.ts (NEW): the R1 reference spec that locks node's observed behavior for pty-rust to match — the 6 tests covering the 4 divergences (post-exit peek, trailing cursor cell, --seq pacing rounding, and #4). #4 now asserts `run --force` CREATES a session (async-spawn + poll the registry until running — deterministic, no foreground-attach hang). - tests/nesting-prevention.test.ts: the old "--force overrides when nested + target running" test encoded the removed no-op behavior (and hung ~10s on a blocking in-place `cat`). Rewritten to deterministically assert the new bypass-and-create behavior. Full suite green (1383 passed, 21 pre-existing env-gated skips). pty-rust is already in lockstep at CREATES.
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.
Parity drive R1 — node reference spec +
run --forcefix (#4)Locks node pty's observed behavior so the Rust port (pty-rust) can match it, and
fixes the one R1 divergence CoS ruled on.
The #4 fix (behavior change)
pty run --forcefrom inside a pty session used to treat--forceas ano-op: it still ran the command directly in-place and created no session.
That contradicted:
run --help— "Create even from inside another pty session"attach/restart--forcesymmetry (those bypass the nesting guard)CoS ruling (decision a, 2026-07-21): fix the node code so
run --forcebypasses run's nesting guard and creates a real (nested) session.
--forcenow behaves like
-dw.r.t. the guard — both fall through to session creation(
-d→ detached/background,--force→ interactive/attached).Changes
src/cli.ts— add&& !forceto therunnesting guard so--forcefalls through to
cmdRun(create + attach a nested session). The inner-a"refuse when target running" sub-check is now reached only on the no-force
path, so its redundant
!forceis dropped. Comments updated.tests/parity-node-reference.test.ts(new) — the R1 reference spec: 6tests over the 4 divergences (post-exit peek preserves final screen, plain
peek keeps the trailing cursor cell,
--seqpacing incl. ms rounding, andposix_spawnp fails on Node.js v25 #4). posix_spawnp fails on Node.js v25 #4 now asserts
run --forceCREATES a session via async-spawn +registry poll (deterministic; no foreground-attach hang).
tests/nesting-prevention.test.ts— the old "--force overrides whennested + target running" test encoded the removed no-op behavior (and hung
~10s on a blocking in-place
cat). Rewritten to deterministically assert thenew bypass-and-create behavior.
test change, slightly beyond "the 6 tests + posix_spawnp fails on Node.js v25 #4 fix" — the code fix inverts
that test's premise, so leaving it would ship a test with a now-false comment.
Verification
skipIf), 0 failed.dist/is gitignored; rebuilt locally before running (tests exercisedist/cli.js).Coordination
pty-rust is already in lockstep at CREATES (flipped + pushed, 167 green).
Node was the outlier; this brings code == docs == rust. R2 shared fixtures next.
/cc CoS for review + merge (author does not self-merge).