Skip to content

feat: let apps flush their content before saving - #4219

Merged
AlexAndBear merged 4 commits into
mainfrom
feat/app-flush-content-callback
Nov 24, 2026
Merged

AlexAndBear merged 4 commits into
mainfrom
feat/app-flush-content-callback

Conversation

@AlexAndBear

@AlexAndBear AlexAndBear commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Description

  • Flush hook for apps: apps can now register an optional register:onFlushContentCallback. AppWrapper runs it as part of every save (save button, Ctrl+S, autosave, the unsaved changes dialog, download and delete) and before it decides about unsaved changes (closing, leaving the app) or "Save as". So apps that only write their content on demand, like the PDF viewer, always get their latest state saved, without intercepting the save button or the keyboard shortcut themselves.
  • Saves still in their flush count as running: saving and closing right away waits for that save instead of asking about unsaved changes and saving a second time.
  • Failures: if the callback fails, the save is dropped with one error message, and the file counts as having unsaved changes, so closing still asks and a delete keeps the file.
  • Unchanged content: a save that finds nothing new after the flush doesn't write a new version.
  • Non-breaking: apps that don't register the callback keep their behavior.

Related Issue

How Has This Been Tested?

  • test environment: unit tests (Vitest), browser tests (Playwright) against a local OpenCloud, Chromium desktop and Pixel 7 viewport
  • test case 1: unit: the callback runs before save, Ctrl+S, autosave, download, "Save as" and leaving the app, and its content is what gets saved; a failing callback drops the save and still asks on close; save then leave while the flush is pending gives one PUT and no dialog; an idle autosave tick saves nothing; a stale callback isn't called after the app switched files
  • test case 2: browser: PDF viewer with the hook and without its workarounds: save button and Ctrl+S while typing, typing during a slow save stays unsaved, drawing then closing, save then close right away on a slow machine, download and "Save as" right after an edit, delete after an edit, form scripts, read-only, one PUT each
  • test case 3: browser: text editor (txt and md) unchanged: save button, Ctrl+S while typing, autosave with and without changes, unsaved changes dialog, download, "Save as" and delete with unsaved changes, collaborative editing with two users; Apollon save and close

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@AlexAndBear AlexAndBear self-assigned this Nov 3, 2026
@AlexAndBear
AlexAndBear marked this pull request as draft November 3, 2026 08:24
@AlexAndBear

Copy link
Copy Markdown
Member Author

convertig to draft, not relevant for the production release

@AlexAndBear
AlexAndBear force-pushed the feat/app-flush-content-callback branch from 374b462 to fb7ca9f Compare November 9, 2026 11:32
@codacy-production

codacy-production Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 38 complexity · 2 duplication

Metric Results
Complexity 38
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@AlexAndBear
AlexAndBear marked this pull request as ready for review November 24, 2026 10:48
Assisted-by: Claude Code:claude-opus-5-5
Flush the app inside saveFileTask, so a leave or another save waits for a
save that is still flushing instead of asking about or saving the same
changes again. Forget the flush callback when the app is remounted for
another file.

Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
@AlexAndBear
AlexAndBear force-pushed the feat/app-flush-content-callback branch from fb7ca9f to 40739d8 Compare November 24, 2026 12:03
@AlexAndBear
AlexAndBear merged commit ff7728c into main Nov 24, 2026
30 checks passed
@AlexAndBear
AlexAndBear deleted the feat/app-flush-content-callback branch November 24, 2026 13:04
@openclouders openclouders mentioned this pull request Nov 24, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AppWrapper: let apps bring their content up to date before saving

2 participants