fix(pty): strip inherited TERMINFO from tab child env - #276
Conversation
Roost forces TERM=xterm-256color on both UIs but let the launching terminal's TERMINFO through, pointing strict $TERMINFO readers (Go/Rust TUI terminfo loaders that don't fall back like ncurses) at a private DB with no entry for the advertised TERM — e.g. Ghostty's, which ships only ghostty/xterm-ghostty. Remove it in both spawn paths. Extracts the Mac env construction into a pure childEnvironment() so the contract is testable without a PTY (the PTY-touching Swift tests are disabled under swift-testing). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WLKWsLV45DAk61xG6Utj3e
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 40 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughPTY child environment construction now removes inherited ChangesPTY environment handling
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/roost-linux/tests/pty_smoke.rs (1)
112-146: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winSerialize and restore the environment mutation.
crates/roost-linux/tests/pty_smoke.rs:119mutates the process environment while multi-threaded tests run. Other tests callPtySupervisor::spawn, which reads environment variables incrates/roost-linux/src/daemon/pty.rs:681-757; POSIX environment reads and writes are not thread-safe. Serialize this test with those tests and restore or remove the previousTERMINFOvalue with a cleanup guard.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/roost-linux/tests/pty_smoke.rs` around lines 112 - 146, Update pty_injects_roost_env_vars to serialize its environment mutation with other PtySupervisor::spawn callers, using the test’s existing synchronization mechanism if available. Capture the prior TERMINFO value before std::env::set_var and install cleanup that restores it or removes TERMINFO when it was previously unset, including on failure or panic.
🧹 Nitpick comments (1)
mac/Sources/Roost/PtySupervisor.swift (1)
542-547: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the leftover
shouldBashBootstrapdoc comment stacked abovebuildEnv.
mac/Sources/Roost/PtySupervisor.swift:542-547still carries the doc comment that used to describe the inlineshouldBashBootstrapfunction. That function moved to file scope atmac/Sources/Roost/PtySupervisor.swift:567-577, with its own copy of the same comment at lines 567-572. The old copy is now orphaned directly abovebuildEnv's doc comment (lines 548-549), which reads as if it explainsbuildEnv.Delete the duplicate block so
buildEnvonly carries its own doc comment.🧹 Proposed cleanup
- /// Whether to bash-auto-bootstrap `resolvedArgv`: the pure predicate - /// (`bashAutobootstrap`) AND the shipped roost.bash being present at - /// `resourcesDir`. `--posix` and the ENV injection must be applied - /// together — a `--posix` shell with no ENV script to source would be - /// stuck in POSIX mode with no startup recreation — so `buildArgv` and - /// `buildEnv` both gate on this. /// Build the NULL-terminated envp array. Inherits the /// parent's environment then overlays Roost's injected vars. private func buildEnv(tabID: Int64, socketPath: String, argv: [String])🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@mac/Sources/Roost/PtySupervisor.swift` around lines 542 - 547, Remove the orphaned duplicate shouldBashBootstrap documentation block immediately before buildEnv in PtySupervisor.swift, leaving only buildEnv’s own doc comment there. Preserve the identical documentation attached to the file-scope shouldBashBootstrap function.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@crates/roost-linux/tests/pty_smoke.rs`:
- Around line 112-146: Update pty_injects_roost_env_vars to serialize its
environment mutation with other PtySupervisor::spawn callers, using the test’s
existing synchronization mechanism if available. Capture the prior TERMINFO
value before std::env::set_var and install cleanup that restores it or removes
TERMINFO when it was previously unset, including on failure or panic.
---
Nitpick comments:
In `@mac/Sources/Roost/PtySupervisor.swift`:
- Around line 542-547: Remove the orphaned duplicate shouldBashBootstrap
documentation block immediately before buildEnv in PtySupervisor.swift, leaving
only buildEnv’s own doc comment there. Preserve the identical documentation
attached to the file-scope shouldBashBootstrap function.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fd8af035-428e-40a4-aeea-9263ab2d0485
📒 Files selected for processing (4)
crates/roost-linux/src/daemon/pty.rscrates/roost-linux/tests/pty_smoke.rsmac/Sources/Roost/PtySupervisor.swiftmac/Tests/RoostTests/ChildEnvironmentTests.swift
Env mutation moves to its own integration-test binary (own process) so it cannot race the parallel PTY-spawning tests' environment reads. Addresses CodeRabbit review on #276. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WLKWsLV45DAk61xG6Utj3e
M0's TERMINFO remainder shipped (#276) and the color symptom stayed unreproducible. Adds the maintenance table (#281-#289) for work this migration surfaced that shouldn't block a slice, and points M5's facade step at #286. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WLKWsLV45DAk61xG6Utj3e
Summary
Roost forces
TERM=xterm-256coloron both UIs but let the launching terminal'sTERMINFOpass through to tab children. When the app is launched from a terminal with a private terminfo DB (e.g. Ghostty, whose DB ships onlyghostty/xterm-ghostty), strict$TERMINFO-only readers (some Go/Rust TUI terminfo loaders that don't fall back to/usr/share/terminfothe way ncurses does) find no entry for the TERM Roost advertises and can degrade to monochrome.Found while investigating a reported single-color-TUI regression (ultimately not reproducible in any UI — this is the env-hygiene hardening that investigation surfaced; see
docs/development/iced-migration-roadmap.mdM0 onpoc/iced).PtySupervisor.swift: removeTERMINFOin the child env; extract env construction into a purechildEnvironment()so the contract is testable without spawning a PTY (the PTY-touching Swift tests are disabled under swift-testing).roost-linuxdaemon/pty.rs:cmd.env_remove("TERMINFO")in the same spot TERM is forced.Testing
ChildEnvironmentTests(TERMINFO stripped; TERM/COLORTERM/Roost contract forced) — 688 Swift tests pass.pty_injects_roost_env_varsextended: setsTERMINFOin the parent, asserts the spawned child'senvoutput lacks it —cargo test -p roost-linuxgreen.🤖 Generated with Claude Code
https://claude.ai/code/session_01WLKWsLV45DAk61xG6Utj3e
Summary by CodeRabbit
TERMINFOsettings that could cause incorrect terminal behavior.