Repository navigation
mac: the opened file keeps its real name as the entry document - #655
Merged
Merged
Conversation
Opening a file not named main.tex still read as main.tex: `replaceProject` hardcoded the entry document's path, so File > Open (adoptOpenedText), the FLASHTEX_SEED_FILE seed, and Restore Discarded Buffer all renamed the entry to "main.tex". Every tab, diagnostic, caret path and the compile request's entry_path then carried the wrong name — and `attachController` fell into the session-temporary-project branch (documentURL.lastPathComponent never matched the renamed entry), losing the real project root on the helper route. `replaceProject(entryText:named:)` now takes the file's actual name (the default "main.tex" remains for unsaved buffers), and the three callers pass it through. With the name intact the preview controller roots at the file's own directory, so `controllerRoutesFiles` accepts non-main.tex entries and saves/reloads/status route through the helper's rooted ledger. Test updates, each because it codified the renaming: - DocumentFilesTests: new regression test — open paper.tex, assert the entry document, activePath and project.entryPath all say paper.tex, and a restored discarded buffer keeps its name. - DirtySnapshotsTests (direct route): activePath after opening paper.tex is now paper.tex. - DirtySnapshotsControllerTests: the "file not named main.tex is a session project" scenario is extinct; the test now pins the rooted-ledger route — durable keys under the real name, reviewed reload via the helper (viaController), discarded text in undo history/recoverableBuffer rather than the snapshot store (applyDiskState and adoptOpenedText only write snapshots off the ledger route), save writes the real file. - ControllerPipelineReviewTests: Finding 2's save-safety property (the save reaches the file the user opened) now holds through the rooted helper; controllerRoutesFiles flips to true and durable keys use the real name. Implementation-Agent: claude-fable-5 (multi-file project lane) Commit-Executor: claude-fable-5 (direct) Co-authored-by: GoKubar <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
This was referenced Sep 17, 2026
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.
Fixes the owner's most concrete multi-file complaint: "when opening a file not named main.tex, it still reads as main.tex." First PR of the multi-file root-document stack (a); (b)–(e) follow separately.
The bug
ShellModel.replaceProject(entryText:)hardcoded the entry document asmain.tex(ShellModel.swift:769-771). All three entry points renamed the opened file:adoptOpenedText(DocumentFiles.swift:537)FLASHTEX_SEED_FILEstartup seed (ShellModel.swift:619)DocumentFiles.swift:555)So opening
paper.texproduced a project whose entry document,activePath, every tab/diagnostic/caret path, and the compile request'sentry_pathall saidmain.tex. On the preview-controller route it was worse:attachControlleronly roots the helper at the real directory whendocumentURL.lastPathComponent == entry.path, which the renaming made impossible for any other filename — the helper then ran in a session temporary project, losing the real project root (and with it any chance of sibling\inputresolution on that route).The fix
replaceProject(entryText:named:)takes the file's actual name; the three callers pass it (url.lastPathComponent, seed filename,kept.url?.lastPathComponent). The"main.tex"default remains for unsaved buffers with no file behind them. No protocol change —entry_pathwas always dynamic; the producer already resolves includes against thedocumentsarray.Free consequence: with the name intact,
controllerRoutesFiles(DocumentFiles.swift:729-732) now accepts non-main.texentries, so helper-routed save/reload/file-status work for every filename instead of onlymain.tex.Test edits (each justified)
testOpenedFileKeepsItsRealNameAsTheEntryDocument: openspaper.tex, assertsactivePath/documents/project.entryPathall carry the real name; a restored discarded buffer keeps its name too.activePathafter openingpaper.texis nowpaper.tex; the old assertion codified the bug.viaController, discarded text kept in undo history +recoverableBufferrather than the snapshot store (applyDiskStateand the reload paths only write snapshots when!controllerRoutesFiles), and the save still writes the real file.controllerRoutesFilesflips to true, durable keys use the real name, and the on-disk file receives the edited text.Doc comment in
DirtySnapshots.swiftupdated to stop describing the extinct session-copy case.Verification
Swift/AppKit does not build on this Linux box; CI's
macos-26lane (swift build + serialswift testwith the real helpers built and exported) is the verification gate for this PR. No Rust code is touched.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu