Skip to content

fix(cli): run --force creates a nested session inside a pty (parity R1 #4) - #112

Merged
myobie merged 1 commit into
mainfrom
parity/r1-run-force-creates
Jul 21, 2026
Merged

fix(cli): run --force creates a nested session inside a pty (parity R1 #4)#112
myobie merged 1 commit into
mainfrom
parity/r1-run-force-creates

Conversation

@myobie

@myobie myobie commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Parity drive R1 — node reference spec + run --force fix (#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 --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/restart --force symmetry (those bypass the nesting guard)
  • 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. --force
now behaves like -d w.r.t. the guard — both 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 (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 !force is dropped. Comments updated.
  • tests/parity-node-reference.test.ts (new) — the R1 reference spec: 6
    tests over the 4 divergences (post-exit peek preserves final screen, plain
    peek keeps the trailing cursor cell, --seq pacing incl. ms rounding, and
    posix_spawnp fails on Node.js v25 #4). posix_spawnp fails on Node.js v25 #4 now asserts run --force CREATES a session via async-spawn +
    registry poll (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. ⚠️ reviewer note: this is a necessitated
    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

  • Full suite: 1383 passed, 21 skipped (pre-existing env-gated skipIf), 0 failed.
  • New parity posix_spawnp fails on Node.js v25 #4 test runs in ~317ms (no hang).
  • dist/ is gitignored; rebuilt locally before running (tests exercise dist/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).

…#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.
@myobie
myobie merged commit 463bb07 into main Jul 21, 2026
1 check passed
@myobie
myobie deleted the parity/r1-run-force-creates branch July 21, 2026 09:27
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