Extract current-document persistence actions from App.vue#89
Merged
Conversation
Moves every way the current editor document is persisted or exported into a createCurrentDocumentPersistence factory in features/document-session: local-draft autosave, Android document save with its in-flight coalescing flags, draft-to-device save, save-a-copy, sharing, lifecycle flushes, and the recovery-draft plus recents bookkeeping around them (recents marking stays private to the module; its only caller is the Android save path). The existing save/share workflows and document-state transitions are reused unchanged. App destructures the same function names so all call sites — exit prompts, editor menu, incoming-document orchestration, and lifecycle flush — are textually unchanged. The autosave scheduler now receives its two save triggers as deferred closures because the two factories reference each other's handles.
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.
Summary
Fourth PR of the semantic-decomposition series: moves every way the current editor document is persisted or exported out of
App.vueinto acreateCurrentDocumentPersistencefactory infeatures/document-session. Behavior-preserving; the save/share workflows and document-state transitions are reused unchanged, per the TODO.Boundary
The factory owns:
saveDraft) with its target/setting guards and status transitions.saveAndroidDocument) including the in-flight coalescing flags (a save requested during a save re-schedules once the first completes, preserving the changed-during-save path) and the read-only/missing-source/clean short-circuits.Everything App owns is injected: state refs (document state, status, notices, busy flags, prompt flags, stores), editor access (
hasEditor, snapshot, sync), chrome closers, predicates and presentation helpers, store persistence +rememberAndroidDocument(shared with the open paths, so it stays in App), the autosave-scheduler timer handles, natives, settings refs, and loggers. App destructures the same function names — every call site (exit prompts, editor menu/actions sheet, incoming-document orchestration, lifecycle flush) is textually unchanged.One wiring note: the autosave scheduler now receives
saveDraft/saveAndroidDocumentas deferred closures, because the two factories reference each other's handles (scheduler triggers saves; saves clear/reschedule timers) and const initialization order would otherwise TDZ.App.vueshrinks by ~400 lines.Testing
currentDocumentPersistence.test.ts(12 tests) drives the real save/share/copy workflows with mocked natives: draft autosave success + skip guards, Android save success updating recents and dropping the recovery draft, save failure keeping a recovery draft (and the users-message fallback when recovery drafts are disabled), in-flight coalescing with post-completion rescheduling, flush routing and its screen guard, draft-to-device saved/canceled-reopens-prompt paths, save-a-copy clearing the exit prompt and the original recovery draft, share success and the busy guard.mobile-local-draft-lifecycle(autosave + all four lifecycle flush paths),mobile-android-document-lifecycle(save-failure recovery, read-only exit flows),mobile-android-document-actions(save-copy variants, transient access),mobile-share-intent(current-document share paths).