Skip to content

fix(export): restore mobile data sharing and add macOS export - #20173

Merged
Git-on-my-level merged 9 commits into
mainfrom
lane/data-export-fix
Oct 2, 2026
Merged

Git-on-my-level merged 9 commits into
mainfrom
lane/data-export-fix

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Restore mobile Export All Data with cancellable, honest byte progress, a verified disk download, system sharing, and persistent Try Again errors; add macOS Settings > Privacy > Data Controls export with NSSavePanel and atomic saving.
  • Preserve released-client default behavior; updated clients use the additive authenticated GET /v1/users/export?stream=true completion protocol. No timeout, auth policy, deployment control, or completeness requirement is weakened.
  • Round 2 fixes owner-decrypted export fields, auth-session fencing (including A→B→A), ASGI disconnect cleanup, share-only retry, and bounded stale mobile-file cleanup. Image-bearing sections follow text. No durable-job design or new image-omission flag is included.

Production evidence and request limits

User-supplied production evidence: a real GET /v1/users/export for an approximately 4,300-conversation account returned HTTP 504 after 30.4 seconds with zero response bytes. This is supplied evidence, not a production request made or independently reproduced in this task. No production account data or api.omi.me request was accessed.

The eager route constructs and validates the whole export before committing headers. Streaming sends the opening JSON chunk before user-data reads, avoiding that eager first-byte mechanism. This does not establish which production layer generated the supplied 504, nor promise that every large export finishes.

Repository timeout trace:

  • backend/main.py:309-332 wires HTTP_GET_TIMEOUT into TimeoutMiddleware; backend/utils/other/list_budget.py:3-6 documents the production GET budget as 30 seconds.
  • backend/utils/other/timeout.py:20,84-95 has an unset-variable fallback of 120 seconds, and its wait_for(call_next(...)) bounds response setup, not the entire streamed body.
  • The current main-backend deploy uses .github/actions/deploy-backend-stack/action.yml:607-626, with flags rendered from backend/deploy/runtime_env.yaml:2606-2615 and backend/scripts/render_backend_runtime_env.py:140-165. Neither pins --timeout/timeoutSeconds or HTTP_GET_TIMEOUT. The Cloud Run request timeout is therefore inherited from the service, not ascertainable from the checked-in deploy configuration. No live infrastructure read was performed. Do not substitute Cloud Run's creation default for a verified deployed value.

macOS uses the main Python data API (APIClient.baseURL), not the Rust data plane. The separate desktop-backend service does not register routers.users; backend deployment is required separately from client releases.

Review findings addressed

  1. Enhanced-protection exports: the bulk photo reader now uses the owner-scoped photo preparer. An export-scoped read context rejects display decrypt fallbacks, corrupted ciphertext, or wrong-owner keys instead of awarding completion. Normal display tolerance is unchanged outside export. Real encrypted fixtures exercise both export variants for photo bytes, compressed transcripts, manual speaker assignments, historical memory content/evidence through MemoryService, and chat text. backend/database/conversations.py:131,467,493; backend/database/chat.py:89; backend/database/memories.py:175; backend/tests/services/users/test_data_export_strict_reads.py:234,331.
  2. Request deadlines: no durable-job lifecycle or deadline increase is included. Image-bearing photo/frame sections now follow the text sections. Actual truncated-200 downloads produce persistent Try Again failures on mobile and macOS, never a successful partial file. backend/services/users/data_export.py:346-457; app/test/widgets/data_export_test.dart:540; desktop/macos/Desktop/Tests/AccountDataExportTests.swift:442.
  3. Mobile session binding: an immutable owner + session-generation snapshot fences token acquisition, 401 refresh/replay, final file publication, and native share/retry. A→B→A invalidates the original snapshot; stale 401 work cannot sign out the new session. app/lib/services/auth_service.dart:185-201; app/lib/backend/http/shared.dart:62,242,377; app/lib/backend/http/user_data_export.dart:22; app/test/unit/auth_session_snapshot_test.dart:35,66,124,190.
  4. Share failures: a completed download is retained and Retry shares that exact file without another download. Even a captured old Retry callback cannot substitute a newer export or a new owner's snapshot. Share leases are awaited before handoff, with session revalidation afterward. Android's native second copy remains a known limit. app/lib/pages/settings/data_export.dart:231-302,314-427; app/test/widgets/data_export_test.dart:425,470,570,625,670.
  5. Disconnect cleanup: a dedicated response owns an ASGI disconnect listener for specs 2.0 and 2.4, flags cooperative cancellation before cancelling the response, waits for an in-flight bounded read to settle, and deterministically closes the iterator/query streams. Header-send errors, body-send errors, read failures, and normal completion also close the source. backend/services/users/data_export_response.py:60-116; backend/tests/routers/test_users_export_streaming.py:188-461.
  6. Restart-safe cleanup: export start sweeps exact app-owned UUID directories after a 24-hour retention window; at most 200 owned candidates are examined and 20 directories removed. Unrelated temp files do not consume the candidate budget. Links, active sharing, and retained retry paths are protected; cleanup no longer requires an in-memory last-directory pointer. Tests use unique task-owned temporary directories. app/lib/pages/settings/data_export_files.dart:20-56; app/test/unit/data_export_files_test.dart:29-159; app/test/widgets/data_export_test.dart:697.

The fix uses reusable read-context, response-lifecycle, session-snapshot, and file-lifecycle primitives rather than adding source-string guards.

Test plan

All checks use local synthetic fixtures only; logs are retained under /tmp/omi-lane-data-export-logs/.

  • Own worktree backend/.venv created from the pinned macOS lock, Python 3.11.15. PYTHON=.venv/bin/python bash test-preflight.sh: 18 checks passed, no failures; optional integration-service warnings.
  • Canonical BACKEND_UNIT_TEST_FILE_LIST=... bash test.sh: 177 passed across the four original export route/service suites, real encrypted strict-read fixtures, cursor pagination, and memory visibility. Log: backend-test-sh-round2b.log.
  • flutter pub get; focused flutter test export widget/downloader, file cleanup, auth-session snapshot, and existing auth-refresh suites: 68 passed. Touched-source analyzer: no issues. Log: flutter-round2-rework.log (final result; earlier full output in flutter-targeted.log).
  • xcrun swift build -c debug --build-tests --package-path Desktop; xcrun swift test --skip-build --package-path Desktop --filter 'AccountDataExport|UserDataExport': 19 passed. Includes real APIClient truncated-200 → model error → successful Retry. Logs: swift-build.log, swift-test.log.
  • Final mobile lifecycle regressions: export widget suite 22/22 passed, including an unmounted Retry callback and a held native share preventing cleanup/new downloads. Log: final-flutter-widgets.log.
  • Focused make mobile-verify ARGS="fast --paths ...": 23/23 hermetic journeys passed, loopback only. Log: final-mobile-verify.log.
  • Enforced full PYRIGHT_PYTHON=.venv/bin/python bash scripts/typecheck.sh: 0 errors, 9,157 warnings (not a warning-free claim). Log: final-typecheck.log.
  • All three canonical OpenAPI exporter --check surfaces are up to date; Dart --all --check, TypeScript --check, Swift --check, and released app-client compatibility passed. No API/schema change in round 2; checks found no regeneration necessary. Logs: final-openapi-*.log, final-gen-*.log, final-app-client-compat.log.
  • Normal OMI_PR_BODY_FILE=/tmp/omi-export-pr-body-round2.md git push origin HEAD:refs/heads/lane/data-export-fix passed the intact bounded pre-push hook: 58 selected manifest check slots passed, generators and Swift compile passed, and the bounded backend test selection passed. The history-dependent failure-class guard reported SKIP on shallow history, not a verified history verdict. No skip flag, force-push, or policy change was used. Hook evidence: worktree Git metadata omi-preflight/pre-push/preflight.log.
  • Push verified with git ls-remote: remote refs/heads/lane/data-export-fix and local HEAD both equal f455f4dc4a857d299b4cccf5dcf3a9993a91e33e; GitHub PR head matches. Working tree clean; PR remains OPEN and was not merged.
  • Current-main integration still blocked: OMI_PR_BODY_FILE=/tmp/omi-export-pr-body-round2.md make preflight ran and failed at the line-count check's synthetic merge into current origin/main: 99 localization conflicts (49 ARBs and 50 generated Dart files). The successful normal push hook uses the merge-base and does not establish current-main mergeability. Missing INV-MEM-1/INV-MEM-4 metadata citations were added and passed in the push hook. Logs: final-make-preflight-2.log, final-pr-preflight-metadata.log. GitHub currently reports the PR as DIRTY.
  • Conditional upstream integration: fix(app): restore locked-preview card content and drop a stale ChatPage argument so main compiles #20216 is still OPEN at the latest check; merge origin/main after it lands, resolve localization conflicts preserving both sides, and reverify. Its fixes have not been copied into this PR.

Known limits

  • One foreground request is not a durable export. Infrastructure request deadlines, device foregrounding, connectivity, and free storage still limit completion. An interrupted HTTP 200 stream is a failure, not a successful partial archive; both clients require the terminal completion suffix and expose Try Again. Moving images last gets text onto the wire earlier but does not publish partial JSON or bypass completeness. Follow-up: generate an owner-authorized durable export artifact asynchronously, then support resumable downloads with expiring download authorization and a defined retention/deletion policy. That lifecycle is deliberately outside this PR.
  • Main-backend Cloud Run timeout is unverified. The repo documents a 30-second production GET middleware budget but does not pin the deployed Cloud Run request timeout. Verify that serving setting separately; this PR does not change it.
  • Android sharing still makes a second full-file copy. share_plus 11 stages the file in its FileProvider cache on the platform thread. This PR retains a completed export after sharing fails so Try Again only retries sharing; it does not add a custom FileProvider/native share implementation. Very large shares can still block or require additional disk space. A no-copy FileProvider path needs a separate native implementation and device validation.
  • Cancellation is cooperative. Disconnect prevents subsequent bounded reads and deterministically closes the source after an already-running blocking read settles; it cannot forcibly interrupt a synchronous SDK RPC already in progress.
  • Temporary-file cleanup is bounded and conservative. Cleanup runs at export start rather than eagerly deleting a file while a receiver may still be using it. It is limited to exact app-owned directory identities, skips active/retained exports and links, and uses a retention window; app/OS termination and delayed receivers remain subject to that policy.

Real-device verification limits

Physical iPhone/iPad/Android share/save sheets, large-file Android platform-thread latency/copying, native macOS NSSavePanel, foreground/background transitions, app restart with a real receiving app, and production Cloud Run/load-balancer streaming are NOT VERIFIED. Hermetic tests exercise production APIs with synthetic transport/auth/filesystem fixtures; compilation is not a claim of device behavior. No native install or production-account test is performed in this task.

Product invariants affected

  • INV-MEM-3: retain MemoryService/privacy authority and owner-scoped decrypted reads; failure never grants completion authority.
  • INV-MEM-1: retain the three memory tiers and explicit owner-portability Archive inclusion; no new memory store or default-access policy.
  • INV-MEM-4: retain canonical lineage, promotion, and suppression authority; this read-only export does not perform capture, promotion, or projection writes.
  • INV-AUTH-1: macOS retains owner-generation authorization and existing session ownership; mobile export captures owner plus auth-session generation through token acquisition, 401 replay, publication, and share retry.
  • INV-UI-1, INV-UI-2, INV-UI-3: shared progress, feedback, controls, and sheets.
  • INV-MEM-5, INV-DATA-1: no alternate account authority, cohort, or desktop data-plane routing.

Failure-Class: none

Line-Count-Exception: backend/database/chat.py | 1499 -> 1507 | Keep the existing owner-scoped message reader and bulk export iterator as the decryption/cancellation boundary; the reusable strict-read primitive lives outside this file
Line-Count-Exception: backend/database/conversations.py | 3458 -> 3483 | Wire export-only verified transcript/photo/manual-speaker reads and cooperative bulk cancellation into the existing owner-scoped read helpers without duplicating decryption logic
Line-Count-Exception: backend/database/memories.py | 1605 -> 1610 | Add export-only fail-closed content/evidence verification to the existing historical memory decryptor while preserving normal display tolerance
Line-Count-Exception: backend/routers/users.py | 2521 -> 2547 | Preserve the established released-client export route and OpenAPI identity; additive streaming/completion wiring stays here while disconnect lifecycle and serialization live in feature modules
Line-Count-Exception: backend/utils/memory/memory_service.py | 4342 -> 4374 | Preserve canonical privacy and suppression authority while adding cooperative export scan checks and deterministic closure of the owned canonical/historical iterators

Generated with Devin

Git-on-my-level and others added 2 commits October 1, 2026 20:49
Failure-Class: none

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mintlify

mintlify Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Oct 2, 2026, 6:04 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T03:41:04.432277Z f9d80cb New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fec04a2589

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 125 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread app/lib/pages/settings/data_export.dart Resolved
Git-on-my-level and others added 3 commits October 2, 2026 03:36
Fail closed on unreadable encrypted fields, stop reads on disconnect, and
retain completed downloads for owner-bound share retries and stale cleanup.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Ignore stale UI callbacks and prove an active share cannot trigger cleanup.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
# Conflicts:
#	app/lib/l10n/app_ar.arb
#	app/lib/l10n/app_be.arb
#	app/lib/l10n/app_bg.arb
#	app/lib/l10n/app_bn.arb
#	app/lib/l10n/app_bs.arb
#	app/lib/l10n/app_ca.arb
#	app/lib/l10n/app_cs.arb
#	app/lib/l10n/app_da.arb
#	app/lib/l10n/app_de.arb
#	app/lib/l10n/app_el.arb
#	app/lib/l10n/app_en.arb
#	app/lib/l10n/app_es.arb
#	app/lib/l10n/app_et.arb
#	app/lib/l10n/app_fa.arb
#	app/lib/l10n/app_fi.arb
#	app/lib/l10n/app_fr.arb
#	app/lib/l10n/app_he.arb
#	app/lib/l10n/app_hi.arb
#	app/lib/l10n/app_hr.arb
#	app/lib/l10n/app_hu.arb
#	app/lib/l10n/app_id.arb
#	app/lib/l10n/app_it.arb
#	app/lib/l10n/app_ja.arb
#	app/lib/l10n/app_kn.arb
#	app/lib/l10n/app_ko.arb
#	app/lib/l10n/app_localizations.dart
#	app/lib/l10n/app_localizations_ar.dart
#	app/lib/l10n/app_localizations_be.dart
#	app/lib/l10n/app_localizations_bg.dart
#	app/lib/l10n/app_localizations_bn.dart
#	app/lib/l10n/app_localizations_bs.dart
#	app/lib/l10n/app_localizations_ca.dart
#	app/lib/l10n/app_localizations_cs.dart
#	app/lib/l10n/app_localizations_da.dart
#	app/lib/l10n/app_localizations_de.dart
#	app/lib/l10n/app_localizations_el.dart
#	app/lib/l10n/app_localizations_en.dart
#	app/lib/l10n/app_localizations_es.dart
#	app/lib/l10n/app_localizations_et.dart
#	app/lib/l10n/app_localizations_fa.dart
#	app/lib/l10n/app_localizations_fi.dart
#	app/lib/l10n/app_localizations_fr.dart
#	app/lib/l10n/app_localizations_he.dart
#	app/lib/l10n/app_localizations_hi.dart
#	app/lib/l10n/app_localizations_hr.dart
#	app/lib/l10n/app_localizations_hu.dart
#	app/lib/l10n/app_localizations_id.dart
#	app/lib/l10n/app_localizations_it.dart
#	app/lib/l10n/app_localizations_ja.dart
#	app/lib/l10n/app_localizations_kn.dart
#	app/lib/l10n/app_localizations_ko.dart
#	app/lib/l10n/app_localizations_lt.dart
#	app/lib/l10n/app_localizations_lv.dart
#	app/lib/l10n/app_localizations_mk.dart
#	app/lib/l10n/app_localizations_mr.dart
#	app/lib/l10n/app_localizations_ms.dart
#	app/lib/l10n/app_localizations_nl.dart
#	app/lib/l10n/app_localizations_no.dart
#	app/lib/l10n/app_localizations_pl.dart
#	app/lib/l10n/app_localizations_pt.dart
#	app/lib/l10n/app_localizations_ro.dart
#	app/lib/l10n/app_localizations_ru.dart
#	app/lib/l10n/app_localizations_sk.dart
#	app/lib/l10n/app_localizations_sl.dart
#	app/lib/l10n/app_localizations_sr.dart
#	app/lib/l10n/app_localizations_sv.dart
#	app/lib/l10n/app_localizations_ta.dart
#	app/lib/l10n/app_localizations_te.dart
#	app/lib/l10n/app_localizations_th.dart
#	app/lib/l10n/app_localizations_tl.dart
#	app/lib/l10n/app_localizations_tr.dart
#	app/lib/l10n/app_localizations_uk.dart
#	app/lib/l10n/app_localizations_ur.dart
#	app/lib/l10n/app_localizations_vi.dart
#	app/lib/l10n/app_localizations_zh.dart
#	app/lib/l10n/app_lt.arb
#	app/lib/l10n/app_lv.arb
#	app/lib/l10n/app_mk.arb
#	app/lib/l10n/app_mr.arb
#	app/lib/l10n/app_ms.arb
#	app/lib/l10n/app_nl.arb
#	app/lib/l10n/app_no.arb
#	app/lib/l10n/app_pl.arb
#	app/lib/l10n/app_pt.arb
#	app/lib/l10n/app_ro.arb
#	app/lib/l10n/app_ru.arb
#	app/lib/l10n/app_sk.arb
#	app/lib/l10n/app_sl.arb
#	app/lib/l10n/app_sr.arb
#	app/lib/l10n/app_sv.arb
#	app/lib/l10n/app_ta.arb
#	app/lib/l10n/app_te.arb
#	app/lib/l10n/app_th.arb
#	app/lib/l10n/app_tl.arb
#	app/lib/l10n/app_tr.arb
#	app/lib/l10n/app_uk.arb
#	app/lib/l10n/app_ur.arb
#	app/lib/l10n/app_vi.arb
#	app/lib/l10n/app_zh.arb

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b6689afcb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/lib/pages/settings/data_export.dart Resolved
Backend: register the export iterators in the Firestore query-driver
registry under their module path, resolve the Firestore client at call
time with a keyword-only seam, and expose the real portability_read
module to the two test files that stub utils.other.

Mobile: delete the export directory when the share sheet is dismissed,
stop protecting a retained export that belongs to a signed-out or
switched account, and assert that no .part files survive a failure.

macOS: invalidate the captured session after a second export 401,
record the auth-retry outcome, unregister the automation action when
Settings disappears, and move the view's coverage to a flow step that
drives the visible export row.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9d80cb4b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/lib/pages/settings/data_export.dart Resolved
Comment thread app/lib/backend/http/shared.dart Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

…token refresh

The retry share now keeps the export directory only after a successful
share. A snapshot-bound request falls back to the session's still-valid
stored token when the forced refresh fails transiently; expired tokens
and stale snapshots still fail closed.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Git-on-my-level
Git-on-my-level merged commit f869493 into main Oct 2, 2026
60 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/data-export-fix branch October 2, 2026 07:10
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.

1 participant