Fix JSONC comment skipper for CRLF line endings
Summary
- Swift treats
\r\nas a single extended grapheme cluster, so the//comment skippers inJSONCParser.swift(3 sites) comparedsource[index] != \"\n\"and walked past CRLF line endings, stripping everything after the first line comment. - On a CRLF cmux.json,
preprocess()returned truncated JSON andloadCmuxSettingsRoot()/jsonObject()threwUnexpected end of file, which is why the nightly tmux corpus terminal-nightly job has been failing ontestSurfaceResumeApprovalWritesRecordsIntoCmuxJSONsince 2026-05-23. - Adds a small helper
isLineTerminator(_:)that matches any character whose first scalar is CR or LF, and uses it in all three call sites. - Also enables
workflow_dispatchto run the macOSterminal-nightlyjob so the same tests can be re-run on demand against PRs (instead of waiting for the next schedule).
Repro of the underlying bug:
let s = "// comment\r\nrest\r\n"
var i = s.startIndex
while i < s.endIndex && s[i] != "\n" { i = s.index(after: i) }
// i is now s.endIndex — the loop ate the rest of the file
Test plan
-
tmux corpusworkflow_dispatch on this branch goes green (specificallycmuxTests/SessionPersistenceTests/testSurfaceResumeApprovalWritesRecordsIntoCmuxJSONandtestRestoreDoesNotRunUntrustedSurfaceResumeBindingByDefault) - CI passes
- Sanity: existing tests that use LF cmux.json still work (unchanged path; terminator check is a superset of
\n)
🤖 Generated with Claude Code
[!NOTE]
Low Risk
Narrow parsing fix for JSONC comment/line boundaries plus a CI trigger change; no auth, security, or broad API surface changes.
Overview
Fixes JSONC // line-comment handling when config text uses CRLF line endings. Swift treats \r\n as one character, so loops that stopped only on \n could consume the rest of the file, truncate preprocessed JSON, and break cmux.json load paths (including session persistence tests on macOS).
Adds JSONCParser.isLineTerminator(_:) (CR or LF on the first scalar) and uses it everywhere line comments and “start of line” scanning used to compare against \n alone.
Also lets the tmux corpus terminal-nightly job run on workflow_dispatch, not only on schedule, so the same macOS terminal corpus can be re-run from a branch.
Reviewed by Cursor Bugbot for commit a7ef5d6e51b46cb7db1e694e0022bd9cd4fcdd98. Bugbot is set up for automated code reviews on this repo. Configure here.
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.
Summary by cubic
Fixes JSONC // comment parsing and indentation detection for CRLF files to prevent truncation and misaligned inserts, restoring tmux corpus stability. Also enables manual runs of the macOS terminal-nightly workflow.
-
Bug Fixes
- Added
isLineTerminator(_:)and used it in three//comment loops to stop at CR, LF, or CRLF and avoid truncating files. - Used the same helper when scanning to the start of a line to fix indent detection on CRLF, keeping inserted properties aligned.
- Added
-
New Features
- Enabled
workflow_dispatchfor theterminal-nightlyjob to re-run tmux corpus tests on demand.
- Enabled
Summary by CodeRabbit
- Bug Fixes
- Improved parsing of JSON-with-comments files to correctly recognize all common line endings (LF, CR, CRLF). This prevents comment text from spilling into following lines, preserves correct indentation detection, and fixes parsing errors or misformatting when files use different platform line endings.