fix: add -L flag for screen log capture on macOS 4.00.03 (issue #96)#98
Merged
fix: add -L flag for screen log capture on macOS 4.00.03 (issue #96)#98
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: #96
Replace the version-dependent approach (native -Logfile for screen >= 4.5.1, tee fallback for older versions) with a unified screenrc-based approach that works on ALL screen versions including macOS bundled 4.00.03. The screenrc uses three directives: - `logfile <path>` sets the log file path (available since early screen) - `logfile flush 0` forces immediate buffer flush (no 10-second delay) - `deflog on` enables logging for all windows by default This eliminates the tee fallback which had reliability issues on macOS: - tee's write buffers may not be flushed before the session ends - TOCTOU race between session detection and file read was hard to mitigate Additional improvements: - Exit code capture via sidecar file ($? saved after command completes) - Enhanced retry logic with 3 retries and increasing delays (50/100/200ms) - Debug output responds to both START_DEBUG and START_VERBOSE env vars - Descriptive [screen-isolation] prefix on all debug messages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…sue #96) New test cases in both JS and Rust: - Verify exit code capture from failed commands (nonexistent command → 127) - Verify stderr output is captured via screen logging - Verify multi-line output with correct exit code (JS only) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update case study to document the complete fix history: - v0.24.9 partial fix (logfile flush 0 + tee retry) that failed on macOS - v0.25.0 complete fix (unified screenrc-based logging) that works on all versions - Root cause analysis of tee fallback reliability issues - Discovery of deflog on + logfile screenrc approach - Exit code capture bug documentation Add experiment scripts used in investigation: - test-screen-capture-issue96.js: Both native and tee path testing - test-screen-tee-forced.js: Force tee fallback path testing - test-screen-screenrc-logging.js: Screenrc-based logging validation - test-screen-dash-L-screenrc.sh: Shell-level screenrc + -L testing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Bump JS package version from 0.24.9 to 0.25.0 (minor: new behavior) - Add changeset for the screen isolation fix - Add Rust changelog entry for PR #98 - Fix Rust formatting (cargo fmt) and clippy warning Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move screen integration tests from isolation.test.js to screen-integration.test.js to keep isolation.test.js under the 1000-line limit (1070 → 804 lines). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
agent --version does not work in screen isolation…issue #96) Root cause: `deflog on` in screenrc only applies to windows created AFTER screenrc processing. In `screen -dmS` mode, the default window is created BEFORE screenrc is processed. The initial window never had logging enabled, causing all output to be silently lost on macOS screen 4.00.03. Fix: Add `-L` flag to screen invocation to explicitly enable logging for the initial window at creation time. Combined with `logfile <path>` in screenrc, `-L` logs to our custom path. The `-L` flag is available on ALL screen versions including macOS 4.00.03. Additional fixes: - Add --verbose flag support to args parser (sets START_VERBOSE=1) - Make DEBUG evaluation lazy so --verbose flag works at runtime - Fix prettier formatting issues flagged by CI - Revert manual version change in package.json (CI doesn't allow it) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…sue #96) Documents the discovery that `deflog on` only applies to NEW windows, not the initial window in `-dmS` mode. This was the root cause of the v0.25.0 failure on macOS screen 4.00.03. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit 7ffa4db.
Member
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
Member
Author
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
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.
Summary
Fixes #96 —
agent --versionproduces no output when run through$ --isolated screen -- agent --versionon macOS with screen 4.00.03.Root Cause
The previous fix (v0.24.9/PR #97) used
deflog onin screenrc to enable logging. However,deflog ononly applies to windows created AFTER screenrc is processed. Inscreen -dmSmode, the default window is created BEFORE screenrc processing — so the initial window (where the command runs) never had logging enabled. This caused all output to be silently lost.Fix
-Lflag to screen invocation:screen -dmS session -L -c screenrc ...-Lexplicitly enables logging for the initial window at creation time-Lis available on ALL screen versions (including macOS 4.00.03)logfile <path>in screenrc,-Llogs to our custom path--verboseflag support to args parser — setsSTART_VERBOSE=1so screen-isolation debug output is visible when troubleshootingisDebug()function instead of constant, so env vars set by--verboseflag are respected at runtimeecho $? > exitfile)logfile <path>,logfile flush 0,deflog onfor immediate flush and additional window coverageChanges
js/src/lib/screen-isolation.js-Lflag, lazyisDebug(), screenrc loggingrust/src/lib/isolation_screen.rs-Lflag, matching Rust implementationjs/src/lib/args-parser.js--verboseflag supportjs/test/screen-integration.test.jsjs/package.jsondocs/case-studies/issue-96/deflog ontiming issueKey Insight
From the GNU Screen manual:
deflog onsets "the default log state for all new windows." The word "new" is critical — the initial window in-dmSmode is not "new" from the screenrc's perspective. The-Lflag bridges this gap by enabling logging at window creation time.Test plan
-L+ screenrc approach works🤖 Generated with Claude Code