Skip to content

fix(staged): improve action output with PTY support and carriage return handling#557

Merged
matt2e merged 3 commits intomainfrom
action-output
Mar 31, 2026
Merged

fix(staged): improve action output with PTY support and carriage return handling#557
matt2e merged 3 commits intomainfrom
action-output

Conversation

@matt2e
Copy link
Copy Markdown
Contributor

@matt2e matt2e commented Mar 31, 2026

Summary

  • Use PTY for action output execution so progress bars and other terminal features overwrite correctly
  • Handle carriage returns correctly in action output display by extracting output processing into a dedicated module with tests
  • Include frontend vitest tests in justfile ci and check-all recipes

Test plan

  • Added processOutput.test.ts with unit tests for carriage return handling
  • Frontend vitest tests included in CI

🤖 Generated with Claude Code

matt2e and others added 3 commits March 31, 2026 14:21
…dd tests

Extract processChunksToLines into a testable utility module and fix a bug
where \r\n split across chunk boundaries was incorrectly treated as a bare
\r (clearing the line) followed by a \n (pushing an empty line). Add vitest
and comprehensive tests covering progress bar overwriting, CRLF handling,
and cross-chunk boundary edge cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ll recipes

The test recipe only ran Rust tests, so the new vitest frontend tests
were never executed by the justfile or the pre-push git hook. Add a
test-frontend recipe and wire it into ci and check-all.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rectly

Child processes detect they're writing to a pipe (not a TTY) and fall back
to \n-separated output instead of \r-based overwriting for progress bars.
Fix this by opening a PTY pair and redirecting the child's stdout/stderr to
the PTY slave, so isatty() returns true. The PTY master is read in the
parent for output streaming.

Key changes:
- Add pty module with open() and configure() helpers using libc::openpty
- Disable echo on PTY so piped stdin commands don't appear in output
- Set 200x50 terminal size to prevent progress bar line wrapping
- Redirect stdout/stderr to PTY slave via dup2 in pre_exec
- Read output from PTY master (single merged stream) instead of pipes
- Remote execution still uses pipes (PTY only affects local execution)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt2e matt2e requested review from baxen and wesbillman as code owners March 31, 2026 05:09
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91b9626149

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +45 to +49
if (pendingCR) {
pendingCR = false;
if (ch === '\n') {
// \r\n split across chunks — treat as a single newline
lines.push({ text: currentText, stream: currentStream });
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Gate split-CRLF handling by stream

The pendingCR branch currently treats any next \n as the completion of a prior \r, even when that \n comes from a different stream chunk. In mixed stdout/stderr output (still possible when chunks are interleaved from separate streams), a stdout chunk ending in \r followed by a stderr chunk starting with \n will be misinterpreted as CRLF and incorrectly preserve/finalize the stdout line instead of applying carriage-return overwrite semantics. The CRLF-bridging logic should only trigger when the continuation chunk is from the same stream as the pending \r.

Useful? React with 👍 / 👎.

@matt2e matt2e merged commit 946b8a5 into main Mar 31, 2026
7 checks passed
@matt2e matt2e deleted the action-output branch March 31, 2026 05:26
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