Conversation
The wasm Document sent isEditable, isSavable, edit and save to the document of the session. A txt has no document, so each call threw NoDocumentFile, and a .txt could not be saved from the browser. Python, Java and Objective-C were not affected, because they bind TextFile::write_edited. For a text file, the four calls now use the TextFile. The edit puts the edited bytes in place of the session's file, so the next render shows them. The save writes the file as UTF-8. TextFile::is_savable now also requires FileType::text_file. JsonFile is a TextFile too, so a json view was editable and write_edited wrote it, but the table declares json unsaved. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ZehrLdwNTE8sBLxNZZYpW
A host saved a document with edit and save, but a plain text file with write_edited. So each binding had to tell a txt from a document before a save. TextFile now has edit, save and save_to_memory. The edit keeps the text in the file of the text engine, so every handle over the file and the next render see it. The save writes the text as UTF-8. Python, Java, Objective-C and Swift bind the new names, and the wasm binding uses them instead of a reopen of the edited bytes. write_edited stays in core and in every binding, and its doc marks it deprecated, so no caller breaks. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ZehrLdwNTE8sBLxNZZYpW
Black joined the edit call in test_file.py, so the format job passes. The changelog entries, the TextFile::edit doc and decision 3 of txt-editing.md no longer tell what the code did before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ZehrLdwNTE8sBLxNZZYpW
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.
Problem
In the npm package, a
.txtfile cannot be saved.Document.isEditable,isSavable,editandsaveall send the call to the document of the session. A text file has no document, so each call throwsNoDocumentFile. Butcapabilities().saveistruefor a txt, andwasm/README.mdsays that txt can be saved.In Python, Java and Objective-C/Swift, a txt can be saved, but only with
TextFile.write_edited/writeEdited. A document useseditandsave, so a host has to tell a txt from a document before a save.A check of all bindings also found a bug in core.
TextFile::is_savablechecked only the encoding, but the docs of the bindings say that it is false for a file type that the library does not write.JsonFileis anabstract::TextFiletoo. Thus a json file reported that it was savable, its view wrotedata-odr-editable="true", andwrite_editedwrote it. The file type table declares json withouteditorsave.Change
TextFilegets the names ofDocument:edit(operations)keeps the edit in the file of the text engine. Every handle over the file and the next render see it.save(path),save(ostream)andsave_to_memory()write the text as UTF-8.write_editedstays, and its doc marks it deprecated. No caller breaks.TextFile::is_savableis false where the file type is nottext_file.edit,saveandsave_to_memory/saveToMemory.write_edited/writeEditedstays, marked deprecated. Java uses@Deprecated.isEditable,isSavable,editandsaveuse theTextFile, so a host uses the samedoc.edit(...)anddoc.save()as for a document.save(password)throwsUnsupportedOperation.docs/design/txt-editing.mdnow describes theDocumentnames.editing.md, the wasmAGENTS.mdandREADME.md, and the changelog are updated too.Tests
TextFile.an_edit_stays_in_the_file_until_it_is_savedandTextFile.json_is_not_savable. The test for an encoding that cannot be decoded also coverseditandsave.NoDocumentFilerefusal for a pdf.edit+save+save_to_memory. The oldwrite_editedtests stay, to show that the aliases still work.Verification
All suites ran locally on macOS:
odr_test --gtest_filter='TextFile.*:*apabilit*'pytest python/tests/test_file.pyctest --test-dir .../jni)swift teston the macOS xcframeworkThe changed C++ files also compile with
-Werror -Wall -Wextra. The test data has no json inputs, so no reference output changes.🤖 Generated with Claude Code
https://claude.ai/code/session_018ZehrLdwNTE8sBLxNZZYpW