Skip to content

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

Done

Description

@AlexAndBear

Initial Checklist

  • I understand this is a feature request and questions should be posted in the Community Discussions
  • I searched issues and couldn't find anything (or linked relevant results below)

Idea

Some apps only turn their edits into file content on demand, because doing it after every edit is too expensive. PDF Studio (opencloud-eu/web-extensions#618) is one of them: PDF.js writes the whole PDF in its worker, which takes seconds for large files, so the app can't emit update:currentContent after every change.

AppWrapper has the same problem internally for Yjs and solves it with flushPendingContent() before every decision about the content: saving, autosave, Ctrl+S, downloading, leaving the app. Apps can't take part in that. PDF Studio works around it today:

  • it intercepts clicks on #app-save-action in the capture phase and runs its own save first, which depends on the DOM id and on the button only reacting to click;
  • it writes its content on every pointerdown outside of the app, so isDirty is right when e.g. closing the app asks about unsaved changes.

Proposal

An optional async callback apps can register, e.g. register:onFlushContentCallback, which AppWrapper awaits wherever it calls flushPendingContent() today (and before "Save as"). The app brings currentContent up to date in it, and AppWrapper goes on with the current content and isDirty.

  • Optional and non-breaking: apps that don't register it behave exactly as before.
  • A failing callback must not leave a save, the unsaved changes check or a navigation hanging.
  • beforeunload can't wait for it, same as for Yjs today.

With this, PDF Studio can drop the click interception on the save button.

The original second point of this issue (disabling Save while saving) is dropped: since #4131 a second click waits for the running save instead of hanging, and with a 60 MB PDF the button stays clickable for less than two seconds, without any effect.

Activity

  1. changed the title [-]AppWrapper: let apps finish writing their content before saving, disable Save while saving[/-] [+]AppWrapper: let apps bring their content up to date before saving[/+] on Nov 3, 2026
  2. self-assigned this
    on Nov 3, 2026
  3. moved this from In Progress to Needs Review in OpenCloud Team Boardon Nov 3, 2026
  4. moved this from Needs Review to No status in OpenCloud Team Boardon Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions