Skip to content

Preserve buffered NodeTerminal readLine input - #6679

Merged
tim-smart merged 3 commits into
mainfrom
agent/codex-engineer/39f3da09
Jul 28, 2026
Merged

Preserve buffered NodeTerminal readLine input#6679
tim-smart merged 3 commits into
mainfrom
agent/codex-engineer/39f3da09

Conversation

@tim-smart

@tim-smart tim-smart commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep one readline interface for the terminal scope
  • buffer line events so sequential readLine calls do not drop piped input
  • preserve QuitError after buffered lines are drained at EOF

Testing

  • pnpm --filter @effect/platform-node-shared test --run test/NodeTerminal.test.ts
  • pnpm lint-fix
  • pnpm check
  • verified the two-line and EOF fixtures with Bun 1.3.13

Closes EFF-135

Summary by CodeRabbit

  • Bug Fixes

    • Fixed terminal input handling so buffered lines are preserved across sequential reads.
    • Improved cleanup when terminal input closes or raw mode is disabled.
  • Tests

    • Added coverage for reading multiple lines in sequence and returning them in the correct order.
  • Chores

    • Added a patch release note for the terminal input fix.

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 28, 2026
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b2978de

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 28 packages
Name Type
@effect/platform-node-shared Patch
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@tim-smart, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 15 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 67eed1c3-84f4-4f25-b367-6c5a4db627e2

📥 Commits

Reviewing files that changed from the base of the PR and between 0afdbc8 and b2978de.

📒 Files selected for processing (3)
  • packages/platform-node-shared/src/NodeTerminal.ts
  • packages/platform-node-shared/test/NodeTerminal.test.ts
  • packages/platform-node-shared/test/fixtures/node-terminal.ts
📝 Walkthrough

Walkthrough

NodeTerminal now creates one readline interface per scope, buffers line events in a shared queue, and consumes them sequentially. Tests add a two-line fixture mode and verify both lines are preserved. A patch changeset documents the behavior.

Changes

NodeTerminal buffered reads

Layer / File(s) Summary
Readline queue lifecycle
packages/platform-node-shared/src/NodeTerminal.ts
Replaces scoped RcRef management and per-call listeners with one readline interface, a shared line queue, scoped raw-mode cleanup, and queue-based readLine consumption.
Sequential read validation
packages/platform-node-shared/test/fixtures/node-terminal.ts, packages/platform-node-shared/test/NodeTerminal.test.ts, .changeset/fresh-lines-wait.md
Adds a two-line fixture mode, verifies ordered buffered results, and records a patch release for @effect/platform-node-shared.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • Effect-TS/effect#6676: Also updates NodeTerminal line-reading behavior around closure and buffered input.

Suggested labels: bug

Suggested reviewers: chenxin-yan

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the bug Something isn't working label Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.63 KB 6.63 KB 0.00 KB (0.00%)
batching.ts 9.37 KB 9.37 KB 0.00 KB (0.00%)
brand.ts 6.26 KB 6.26 KB 0.00 KB (0.00%)
cache.ts 10.12 KB 10.12 KB 0.00 KB (0.00%)
config.ts 19.22 KB 19.22 KB 0.00 KB (0.00%)
differ.ts 18.42 KB 18.42 KB 0.00 KB (0.00%)
http-client.ts 20.76 KB 20.76 KB 0.00 KB (0.00%)
logger.ts 10.28 KB 10.28 KB 0.00 KB (0.00%)
metric.ts 8.55 KB 8.55 KB 0.00 KB (0.00%)
optic.ts 7.41 KB 7.41 KB 0.00 KB (0.00%)
pubsub.ts 14.20 KB 14.20 KB 0.00 KB (0.00%)
queue.ts 11.09 KB 11.09 KB 0.00 KB (0.00%)
schedule.ts 10.27 KB 10.27 KB 0.00 KB (0.00%)
schema-class.ts 18.16 KB 18.16 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.02 KB 28.02 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 24.34 KB 24.34 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.69 KB 12.69 KB 0.00 KB (0.00%)
schema-string.ts 10.35 KB 10.35 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.49 KB 14.49 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 20.93 KB 20.93 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 23.38 KB 23.38 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 18.32 KB 18.32 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.00 KB 18.00 KB 0.00 KB (0.00%)
schema-toFormatter.ts 17.88 KB 17.88 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 21.52 KB 21.52 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 18.56 KB 18.56 KB 0.00 KB (0.00%)
schema.ts 17.43 KB 17.43 KB 0.00 KB (0.00%)
stm.ts 12.05 KB 12.05 KB 0.00 KB (0.00%)
stream.ts 9.37 KB 9.37 KB 0.00 KB (0.00%)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@packages/platform-node-shared/src/NodeTerminal.ts`:
- Around line 52-60: Update the readInput setup around readline.createInterface
and the inputEnded state so an already-ended stdin immediately closes the lines
queue with the same QuitError behavior expected by late subscribers. Preserve
the existing rl "close" handler for streams that end after interface creation,
and ensure Queue.take(lines) cannot remain pending when stdin has ended before
readInput runs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 44ef9da2-eca4-4016-acc1-8befac7f6fa2

📥 Commits

Reviewing files that changed from the base of the PR and between 381c141 and 0afdbc8.

📒 Files selected for processing (4)
  • .changeset/fresh-lines-wait.md
  • packages/platform-node-shared/src/NodeTerminal.ts
  • packages/platform-node-shared/test/NodeTerminal.test.ts
  • packages/platform-node-shared/test/fixtures/node-terminal.ts

Comment thread packages/platform-node-shared/src/NodeTerminal.ts Outdated
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Waiting on Author in PR Backlog Jul 28, 2026
Comment thread packages/platform-node-shared/src/NodeTerminal.ts Outdated
@tim-smart
tim-smart merged commit 9f02491 into main Jul 28, 2026
14 of 15 checks passed
@tim-smart
tim-smart deleted the agent/codex-engineer/39f3da09 branch July 28, 2026 02:55
@github-project-automation github-project-automation Bot moved this from Waiting on Author to Done in PR Backlog Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant