saveProject: a registered bridge composes with the OPFS commit - #548
Merged
Conversation
The native bridge hook (#449) predates the project library (#456), and their interaction shipped wrong: registering hyperaudioProjectBridge made saveProject() skip the OPFS commit entirely — an embedder that accepts the container hand-off silently loses saved.json/draft semantics, the undo-aware dirty state, and everything else the library's save provides. With a bridge AND OPFS available, save now commits first and hands the finished container to the bridge afterwards; a bridge failure is the bridge's to report and never un-commits. The bridge-only short-circuit remains for OPFS-less contexts, where the hand-off genuinely IS the save. Behaviour without a bridge is untouched.
Merged
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.
The native bridge hook (#449) predates the project library (#456), and their interaction shipped wrong: registering
hyperaudioProjectBridgemakessaveProject()skip the OPFS commit entirely — an embedder that accepts the container hand-off silently losessaved.json/draft semantics, the undo-aware dirty state, restore-on-reload, and everything else the library's save provides. The hook was designed for OPFS-less wrappers; any embedder that has OPFS gets the worse of both worlds.With a bridge and OPFS available, save now commits first and hands the finished container to the bridge afterwards. A bridge failure is the bridge's to report and never un-commits. The bridge-only short-circuit remains for OPFS-less contexts, where the hand-off genuinely is the save. Behaviour without a bridge is untouched, and
asSave's clean-marking rules apply unchanged.Three lines of logic plus comments; in production use in a native wrapper where every ⌘S runs this path.