Skip to content

documents: route attachments, backups and snapshots through the host provider - #84

Merged
iamdarkle merged 11 commits into
flectar:mainfrom
springmin:pr-document-provider
Oct 18, 2026
Merged

iamdarkle merged 11 commits into
flectar:mainfrom
springmin:pr-document-provider

Conversation

@springmin

@springmin springmin commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Compose attachments, account-backup export/import and database-snapshot
export still opened desktop file dialogs (rfd) directly, so on mobile they
reported "no picker" even though the host provides a DocumentProvider. This
routes all three through the provider.

What changes

  • The document entry points are no longer hidden on mobile:
    document_apis_supported is true on every host now that all of them provide
    a DocumentProvider, so the compose attach button and the Storage
    backup/snapshot cards show up on phones and tablets.
  • DocumentProvider::import_many() imports several documents for one user
    action. The default imports one document per request, so a single-document
    picker (Android, iOS, OpenHarmony) never opens twice for one tap; the desktop
    provider overrides it with one multi-select dialog. The composer keeps the returned documents alive until
    Core has staged the attachments, which is how the trait already describes
    owned import copies.
  • Compose attachments use import_many(); the duplicate, size and 25 MB total
    checks and their notices are unchanged.
  • Account-backup export writes the JSON to an app-private staging file and
    hands it to export(); import awaits import() and then runs the existing
    verified import logic on the UI-thread executor, so the state updates keep
    their current shape.
  • Database-snapshot export still produces Core's verified snapshot, then
    archives it as one zip (hosts export files, not folders) and hands it to
    export(). Staging is created outside the data/cache roots Core requires for
    snapshots, which also covers hosts whose TMPDIR is the app cache. The
    archiver skips symlinks and declares no path outside the snapshot directory.
  • Desktop behavior is unchanged: same dialogs, same file names, same 1 MB
    backup limit. Nothing about the JSON formats or the credential exclusion
    changes.

Validation

  • cargo fmt --all -- --check: clean.
  • python3 scripts/check-platform-gates.py: passes.
  • cargo clippy for the shared application with the mobile configuration
    (OpenHarmony target): clean.
  • New unit tests cover the default import_many (cancellation ends the loop,
    the limit is honored, and dropped imports release their copies).
  • OpenHarmony (HarmonyOS 7.0.0.111, API 26): the port builds and runs with
    these paths wired to the ArkTS pickers; the interactive flows are part of the
    port's manual test matrix (tracked in OpenHarmony (HarmonyOS) platform support — interest in a port contribution? #77).

Contribution and licensing

  • I have the right to submit this work.
  • Third-party dependencies/assets: zip 9.0.4 (MIT, already in the
    dependency graph through flectar-mail-core; the root crate now declares it
    directly with default features off and uses Stored compression only) for the
    snapshot archive. No new asset.
  • Disclosed generative-tool assistance: the change was developed with an AI
    coding agent (LLM); I reviewed every line, ran the checks above, and tested
    the behavior as described.
  • No credentials, private mailbox data, signing material, or unnecessary
    personal information included.

…provider

Compose attachments, account-backup export/import and database-snapshot
export still opened desktop file dialogs directly, so on mobile they
reported "no picker" even though the host provides a DocumentProvider.

- DocumentProvider::import_many() imports several documents for one action
  (default: repeat import() until the picker is cancelled; the desktop
  provider uses one multi-select dialog). Imported documents stay alive in
  the composer until Core has staged the attachments.
- Compose attachments use import_many() instead of rfd::FileDialog.
- Backup export/import stage one app-private file and hand it to the
  provider; the existing import logic keeps its synchronous shape on the UI
  thread executor.
- Database snapshots keep Core's verified snapshot, archive it as one zip
  (hosts export files, not folders) and pass it to the provider. Staging
  stays outside the data/cache roots Core requires.
- Desktop behavior is unchanged: same dialogs and file names.
@springmin
springmin force-pushed the pr-document-provider branch from 624af0e to 2116909 Compare October 17, 2026 16:55
@springmin

Copy link
Copy Markdown
Contributor Author

Note on the RustSec job: it fails on RUSTSEC-2026-0370 / RUSTSEC-2026-0372
(zvariant / zvariant_derive 5.15.0 unmaintained), published 2026-10-16.
This pull request only adds the already-present zip dependency edge to the
lockfile and changes no package versions, so the next scan of main reports
the same advisories. Every other check (format, clippy, tests, all platform
lints) passes on the current head.

@springmin springmin mentioned this pull request Oct 17, 2026
4 tasks done
@springmin

Copy link
Copy Markdown
Contributor Author

FYI for the mobile hosts (not a request to change anything here): on
OpenHarmony the system document picker covers the application window and the
XComponent surface hide callback does not fire for a covered window, so
running the provider future on the runtime leaves the presentation thread
submitting frames into a buffer queue the compositor is not consuming. The
compose window then stops responding after the picker returns (reproduced on
HarmonyOS 7.0.0.111 with the visibility gate active).

The reference OpenHarmony port blocked the calling thread while the picker was
up instead; that is the policy the platform keeps in #85. Desktop targets are
unaffected — the native dialog needs the event loop, which the current design
correctly keeps alive.

@iamdarkle

Copy link
Copy Markdown
Member

Thanks for the heads-up on the OpenHarmony picker, and for this contribution, routing these flows through the document provider is a solid step for the mobile hosts. I added follow-up commits that run the requests on the Tokio runtime (backup export panicked on every platform, and the mobile pickers panicked on their timers outside it), restore the desktop dialog titles and filters, keep the folder picker for desktop snapshots, guard against repeated clicks, and stop mobile snapshot export early when the archive would exceed the 512 MiB transfer limit. CI is green, so this is ready to merge.

For #85, every picker and export now goes through documents::run_request, so after rebasing, the OpenHarmony blocking policy only needs to change that one function. Snapshot export stages and zips on the runtime first, so only the picker step would block. Also note that the desktop branch of with_document_future in #85 awaits the provider future on the UI thread outside the runtime, so desktop backup export panics there because save_cached_file uses tokio::fs. Rebasing onto run_request removes that path.

@iamdarkle
iamdarkle merged commit b236c44 into flectar:main Oct 18, 2026
17 checks passed
springmin added a commit to springmin/mail that referenced this pull request Oct 18, 2026
Tier-3 community port (maintainer: springmin), rebased onto the merged
document-provider abstraction (flectar#84) and the opener seam (flectar#80).

- platform/ohos: Slint backend (XComponent window adapter, software renderer
  with the experimental femtovg/wgpu path, input/IME, clipboard, system
  fonts), the NAPI cdylib that builds a PlatformContext (app-private paths,
  DocumentProvider over the ArkTS pickers, Asset Store credential store,
  loopback OAuth broker, external URL opener, notification publisher) and
  calls flectar_mail::run, the demo crate, the ArkTS shell and the build and
  packaging scripts (bundle name configurable, defaults to
  com.flectar.mail_ohos).
- src/platform/ohos.rs: PDFium directory, renderer name, thread priority,
  preview lifecycle, email font directory; OpenHarmony stays under the
  mobile capability alias.
- patches/fontique + crates/fontique: the Fontconfig opt-out as a patch queue
  applied by the platform/ohos workspace, verified from quality.yml.
- .github/workflows/ohos.yml: manually dispatched tier-3 workflow, unsigned by
  default, signing material only from the FLECTAR_OHOS_* secrets.
- src/documents.rs: run_request blocks the calling thread on mobile hosts;
  the picker covers the window, and keeping the presentation thread idle is
  what OpenHarmony needs (verified on device; desktop keeps the runtime
  request for the native dialog).
- The email renderer and the compose editor load platform::email_font_dir()
  and the Han fallback, so CJK mail bodies and composed text render with the
  platform fonts.
- New-mail notifications: a publisher seam fed by CoreEvent::MailNew; the host
  publishes through @kit.NotificationKit.
springmin added a commit to springmin/mail that referenced this pull request Oct 20, 2026
Tier-3 community port (maintainer: springmin), rebased onto the merged
document-provider abstraction (flectar#84) and the opener seam (flectar#80).

- platform/ohos: Slint backend (XComponent window adapter, software renderer
  with the experimental femtovg/wgpu path, input/IME, clipboard, system
  fonts), the NAPI cdylib that builds a PlatformContext (app-private paths,
  DocumentProvider over the ArkTS pickers, Asset Store credential store,
  loopback OAuth broker, external URL opener, notification publisher) and
  calls flectar_mail::run, the demo crate, the ArkTS shell and the build and
  packaging scripts (bundle name configurable, defaults to
  com.flectar.mail_ohos).
- src/platform/ohos.rs: PDFium directory, renderer name, thread priority,
  preview lifecycle, email font directory; OpenHarmony stays under the
  mobile capability alias.
- patches/fontique + crates/fontique: the Fontconfig opt-out as a patch queue
  applied by the platform/ohos workspace, verified from quality.yml.
- .github/workflows/ohos.yml: manually dispatched tier-3 workflow, unsigned by
  default, signing material only from the FLECTAR_OHOS_* secrets.
- src/documents.rs: run_request blocks the calling thread on mobile hosts;
  the picker covers the window, and keeping the presentation thread idle is
  what OpenHarmony needs (verified on device; desktop keeps the runtime
  request for the native dialog).
- The email renderer and the compose editor load platform::email_font_dir()
  and the Han fallback, so CJK mail bodies and composed text render with the
  platform fonts.
- New-mail notifications: a publisher seam fed by CoreEvent::MailNew; the host
  publishes through @kit.NotificationKit.
springmin added a commit to springmin/mail that referenced this pull request Oct 20, 2026
Tier-3 community port (maintainer: springmin), rebased onto the merged
document-provider abstraction (flectar#84) and the opener seam (flectar#80).

- platform/ohos: Slint backend (XComponent window adapter, software renderer
  with the experimental femtovg/wgpu path, input/IME, clipboard, system
  fonts), the NAPI cdylib that builds a PlatformContext (app-private paths,
  DocumentProvider over the ArkTS pickers, Asset Store credential store,
  loopback OAuth broker, external URL opener, notification publisher) and
  calls flectar_mail::run, the demo crate, the ArkTS shell and the build and
  packaging scripts (bundle name configurable, defaults to
  com.flectar.mail_ohos).
- src/platform/ohos.rs: PDFium directory, renderer name, thread priority,
  preview lifecycle, email font directory; OpenHarmony stays under the
  mobile capability alias.
- patches/fontique + crates/fontique: the Fontconfig opt-out as a patch queue
  applied by the platform/ohos workspace, verified from quality.yml.
- .github/workflows/ohos.yml: manually dispatched tier-3 workflow, unsigned by
  default, signing material only from the FLECTAR_OHOS_* secrets.
- src/documents.rs: run_request blocks the calling thread on mobile hosts;
  the picker covers the window, and keeping the presentation thread idle is
  what OpenHarmony needs (verified on device; desktop keeps the runtime
  request for the native dialog).
- The email renderer and the compose editor load platform::email_font_dir()
  and the Han fallback, so CJK mail bodies and composed text render with the
  platform fonts.
- New-mail notifications: a publisher seam fed by CoreEvent::MailNew; the host
  publishes through @kit.NotificationKit.
springmin added a commit to springmin/mail that referenced this pull request Oct 21, 2026
Tier-3 community port (maintainer: springmin), rebased onto the merged
document-provider abstraction (flectar#84) and the opener seam (flectar#80).

- platform/ohos: Slint backend (XComponent window adapter, software renderer
  with the experimental femtovg/wgpu path, input/IME, clipboard, system
  fonts), the NAPI cdylib that builds a PlatformContext (app-private paths,
  DocumentProvider over the ArkTS pickers, Asset Store credential store,
  loopback OAuth broker, external URL opener, notification publisher) and
  calls flectar_mail::run, the demo crate, the ArkTS shell and the build and
  packaging scripts (bundle name configurable, defaults to
  com.flectar.mail_ohos).
- src/platform/ohos.rs: PDFium directory, renderer name, thread priority,
  preview lifecycle, email font directory; OpenHarmony stays under the
  mobile capability alias.
- patches/fontique + crates/fontique: the Fontconfig opt-out as a patch queue
  applied by the platform/ohos workspace, verified from quality.yml.
- .github/workflows/ohos.yml: manually dispatched tier-3 workflow, unsigned by
  default, signing material only from the FLECTAR_OHOS_* secrets.
- src/documents.rs: run_request blocks the calling thread on mobile hosts;
  the picker covers the window, and keeping the presentation thread idle is
  what OpenHarmony needs (verified on device; desktop keeps the runtime
  request for the native dialog).
- The email renderer and the compose editor load platform::email_font_dir()
  and the Han fallback, so CJK mail bodies and composed text render with the
  platform fonts.
- New-mail notifications: a publisher seam fed by CoreEvent::MailNew; the host
  publishes through @kit.NotificationKit.
springmin added a commit to springmin/mail that referenced this pull request Oct 22, 2026
Tier-3 community port (maintainer: springmin), rebased onto the merged
document-provider abstraction (flectar#84) and the opener seam (flectar#80).

- platform/ohos: Slint backend (XComponent window adapter, software renderer
  with the experimental femtovg/wgpu path, input/IME, clipboard, system
  fonts), the NAPI cdylib that builds a PlatformContext (app-private paths,
  DocumentProvider over the ArkTS pickers, Asset Store credential store,
  loopback OAuth broker, external URL opener, notification publisher) and
  calls flectar_mail::run, the demo crate, the ArkTS shell and the build and
  packaging scripts (bundle name configurable, defaults to
  com.flectar.mail_ohos).
- src/platform/ohos.rs: PDFium directory, renderer name, thread priority,
  preview lifecycle, email font directory; OpenHarmony stays under the
  mobile capability alias.
- patches/fontique + crates/fontique: the Fontconfig opt-out as a patch queue
  applied by the platform/ohos workspace, verified from quality.yml.
- .github/workflows/ohos.yml: manually dispatched tier-3 workflow, unsigned by
  default, signing material only from the FLECTAR_OHOS_* secrets.
- src/documents.rs: run_request blocks the calling thread on mobile hosts;
  the picker covers the window, and keeping the presentation thread idle is
  what OpenHarmony needs (verified on device; desktop keeps the runtime
  request for the native dialog).
- The email renderer and the compose editor load platform::email_font_dir()
  and the Han fallback, so CJK mail bodies and composed text render with the
  platform fonts.
- New-mail notifications: a publisher seam fed by CoreEvent::MailNew; the host
  publishes through @kit.NotificationKit.
springmin added a commit to springmin/mail that referenced this pull request Oct 23, 2026
Tier-3 community port (maintainer: springmin), rebased onto the merged
document-provider abstraction (flectar#84) and the opener seam (flectar#80).

- platform/ohos: Slint backend (XComponent window adapter, software renderer
  with the experimental femtovg/wgpu path, input/IME, clipboard, system
  fonts), the NAPI cdylib that builds a PlatformContext (app-private paths,
  DocumentProvider over the ArkTS pickers, Asset Store credential store,
  loopback OAuth broker, external URL opener, notification publisher) and
  calls flectar_mail::run, the demo crate, the ArkTS shell and the build and
  packaging scripts (bundle name configurable, defaults to
  com.flectar.mail_ohos).
- src/platform/ohos.rs: PDFium directory, renderer name, thread priority,
  preview lifecycle, email font directory; OpenHarmony stays under the
  mobile capability alias.
- patches/fontique + crates/fontique: the Fontconfig opt-out as a patch queue
  applied by the platform/ohos workspace, verified from quality.yml.
- .github/workflows/ohos.yml: manually dispatched tier-3 workflow, unsigned by
  default, signing material only from the FLECTAR_OHOS_* secrets.
- src/documents.rs: run_request blocks the calling thread on mobile hosts;
  the picker covers the window, and keeping the presentation thread idle is
  what OpenHarmony needs (verified on device; desktop keeps the runtime
  request for the native dialog).
- The email renderer and the compose editor load platform::email_font_dir()
  and the Han fallback, so CJK mail bodies and composed text render with the
  platform fonts.
- New-mail notifications: a publisher seam fed by CoreEvent::MailNew; the host
  publishes through @kit.NotificationKit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants