{{ message }}
fix(site): keep TemplateVersionEditor file tree in sync#25068
Merged
Conversation
The editor kept its own local copy of the file tree, while the page kept the initial copy loaded from the tar. The page resolved the active path against its stale tree, so creating a file fell back to the entrypoint and renaming threw 'File is not a text file' from getFileText. Lift the file tree state up to TemplateVersionEditorPage so there is a single source of truth. Add regression tests for create and rename. Generated by Coder Agents.
DanielleMaywood
approved these changes
Jun 26, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

The TemplateVersionEditor kept its own local copy of the file tree, while the page kept the initial copy loaded from the tar. Active path resolution ran against the page's stale tree, so creating a file fell back to the entrypoint and renaming threw
File is not a text filefromgetFileText.Lift file tree state up to
TemplateVersionEditorPageso there is a single source of truth, and add regression tests for the create and rename flows.Implementation plan
Symptoms
getFileTextinfiletree.tsthrows "File is not a text file".Root cause
fileTreelives in two places:TemplateVersionEditorPage(initial copy from tar) andTemplateVersionEditor(local mutable copy viauseState(defaultFileTree)). The parent never sees the child's edits, sogetActivePathvalidates against the parent's stale tree:newfile.tf: child has it, parent does not.existsFile("newfile.tf", parentTree)is false, so the active path falls back tofindEntrypointFile(parentTree)which ismain.tf. The editor opensmain.tfinstead.main.tf→app.tf: child hasapp.tfonly. The fallback returnsmain.tffrom the parent, and the editor callsgetFileText("main.tf", childTreeWithoutMainTf)which throws.Fix
Lift the file tree state up to the page.
useFileTreeexposes asetFileTree, andTemplateVersionEditortakesfileTreeandonFileTreeChangeprops instead ofdefaultFileTree.Generated by Coder Agents.