GeezerVison is showing github.com — id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw · Issue #1307 · developing-today/code
id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw #1307Labels app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item Descriptionid(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw
Summary
Opening a plain-text (.txt) file in id and saving it — even with no
edits — rewrites the file: the final newline is always removed, and
CRLF line endings are converted to LF. Raw mode round-trips
byte-exactly; Plain mode does not.
Evidence
- Load:
pkgs/id/src/web/markdown.rs:1825 plain_text_to_prosemirror
splits with str::lines(), which yields no element for a single
trailing newline and strips the \r of CRLF endings.
- Save:
pkgs/id/src/web/routes.rs:2009 extract_plain_text joins
paragraphs with "\n" and appends nothing at the end — so the
trailing newline the load discarded can never come back.
- Verified this run on origin/main 90f7ea0 with a probe crate running
the real load function plus the verbatim save function (log:
hidden_files/probe-2026-10-26-2352/out3.log):
"alpha\nbeta\n" → "alpha\nbeta" (final newline lost)
"alpha\n" → "alpha"; "\n" → ""; "alpha\n\n" → "alpha\n"
"alpha\r\nbeta\r\n" → "alpha\nbeta" (CRLF rewritten to LF)
- Controls that round-trip exactly:
"alpha\nbeta" (no trailing
newline) and "".
- Contrast: Raw mode (
raw_text_to_prosemirror /
extract_raw_text) keeps the whole file in one code block and
round-trips byte-exactly, including the trailing newline.
Why it matters
Every POSIX text file ends in a newline; a no-op open→save in id
produces a spurious diff (\ No newline at end of file), breaks
tools that require a terminating newline, and silently converts
CRLF files (common for notes shared with Windows editors) to LF.
Fidelity loss in the mode whose entire job is plain bytes.
Acceptance criteria
- A documented, tested policy makes no-edit open→save of a
.txt
file byte-stable for the common shapes: trailing newline present
or absent, and CRLF endings (either preserved, or — if LF
normalization is the deliberate choice — called out in the mode's
docs and pinned by a test, not accidental).
- Regression tests cover at least:
"a\nb\n", "a\nb", "a\n",
"", and a CRLF sample, through the real load→save pair.
- Markdown and Raw save/load behavior unchanged.
Notes
The information loss happens at load (lines() cannot distinguish
"a" from "a\n"), so a fix likely needs the load side to carry the
trailing-newline fact (e.g. a trailing empty paragraph, mirroring how
"a\n\n" already loads) or the save side to adopt an
always-terminate policy — triage should pick and pin one. Activitydeveloping-today commented on Oct 27, 2026 added kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item app/idPackage/app: id (pkgs/ or apps/ in this repo) effort/sSmall: expected under 2 hours of work on Oct 27, 2026dezren39 commented on Oct 27, 2026 🤖 Agent note · state: filed
- Agent: new-issue-creator job
- Session / ID: new-issue-creator run, 2026-10-27T05:34Z
- Found via: filed this run
- Task: Filed after verifying on origin/main 90f7ea0 that the .txt load→save pair (plain_text_to_prosemirror lines() + extract_plain_text join) always drops the final newline and rewrites CRLF to LF, while Raw mode round-trips byte-exactly.
- Expectation: effort s — triage picks the fidelity policy (carry trailing-newline at load, or always-terminate at save; CRLF preserved or documented normalization), then a small fix with round-trip tests.
- Links: probe log hidden_files/probe-2026-10-26-2352/out3.log; queue packet packet-1307.json (repo-health-code-pilot)
dezren39 commented on Nov 2, 2026 🤖 Agent note · done — PR #4613 merged, issue #1307 fixed
dezren39 commented on Nov 8, 2026 🤖 Agent note · done (triaged — already done) via MID-SHIFT FALLBACK
dezren39 commented on Nov 8, 2026
Picked up by repo-worker-code-v — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while repo-worker-code-v posts progress markers; after 30 minutes of silence any other worker may pick this up.) dezren39 commented on Nov 8, 2026
Progress from repo-worker-code-v: done: triage verdict already_done recorded, releasing dezren39 commented on Nov 8, 2026
Released by repo-worker-code-v (outcome: done). task 12763 triaged already_done: PR #4613 merged 1155872, issue #1307 closed, Codex P2 dispositioned+fixed 2548949, plain_mode tests 3/3 (task 6492 record). Broker complete failed not-claimed (double-claim race) — outcome recorded via this fallback release + agent note on #1307.
MetadataMetadataapp/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|