Skip to content

Conversation

@Simon-Laux
Copy link
Contributor

@Simon-Laux Simon-Laux commented Oct 29, 2025

This is the branch for #7367
closes #7367

Currently removed tests

  • test_something.py::test_reaction_to_partially_fetched_msg
  • python/tests/test_1_online.py::test_webxdc_download_on_demand
  • src/calls/calls_tests.py::test_no_partial_calls
  • src/message/message_tests.rs::test_markseen_not_downloaded_msg
  • src/receive_imf/receive_imf_tests.rs::test_download_later
  • src/receive_imf/receive_imf_tests.rs::test_create_group_with_big_msg
  • src/receive_imf/receive_imf_tests.rs::test_prefer_references_to_downloaded_msgs
  • src/receive_imf/receive_imf_tests.rs::test_partial_download_key_contact_lookup
  • src/webxdc/webxdc_tests.rs::test_webxdc_update_for_not_downloaded_instance
  • src/download.rs::test_download_limit
  • src/download.rs::test_partial_receive_imf
  • src/download.rs::test_partial_download_and_ephemeral
  • src/download.rs::test_status_update_expands_to_nothing
  • src/download.rs::test_mdn_expands_to_nothing
  • src/download.rs::test_partial_download_trashed
  • src/reaction.rs::test_partial_download_and_reaction

Progress of the tests

Overview about the recycled(♻️) and dropped(🗑️) tests of the tests that I removed in #7373

All the recycled tests were already recycled/re-made except for some which are still to do:
(none)

Furthermore there need to be new tests to test the downloading/scheduling changes.


TODO Tests

  • sending pre-message, post-message
  • metadata in pre-message
  • process receiving
  • display attachment info in pre-message
  • test scheduler imap fetching
  • test failing download sets state to failed
  • multi device tests
  • deletion tests

postponed to do tests

(none)

discarded/ignored test ideas

maybe we should reconsider / discuss those?

  • test that full message, replacing pre-message does not work if the message encryption state is not the same for both messages (both full- and pre-message)
    • unencrypted pre- and full-message are not sent

@Simon-Laux Simon-Laux changed the title [Branch] Pre-messages / next version of download on demand [Branch] pre-messages / next version of download on demand Oct 29, 2025
@link2xt link2xt force-pushed the pre-messages branch 3 times, most recently from 2f1c383 to 6bcc795 Compare December 11, 2025 12:00
@link2xt link2xt force-pushed the pre-messages branch 6 times, most recently from 8443b17 to 702771f Compare December 11, 2025 21:24
@link2xt link2xt force-pushed the pre-messages branch 2 times, most recently from bb0fd7c to a98fe05 Compare December 14, 2025 17:54
@link2xt link2xt changed the title [Branch] pre-messages / next version of download on demand feat: pre-messages / next version of download on demand Dec 14, 2025
Comment on lines 1475 to 1511
"CREATE TABLE download_new (
rfc724_mid TEXT NOT NULL DEFAULT '',
msg_id INTEGER NOT NULL DEFAULT 0
) STRICT;
Copy link
Collaborator

@Hocuri Hocuri Dec 18, 2025

Choose a reason for hiding this comment

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

@link2xt I'm wondering whether we should add UNIQUE(rfc724_mid) or UNIQUE(msg_id)? Or even both? I guess it doesn't really make sense to have the same message in there twice?

Copy link
Collaborator

@iequidoo iequidoo Dec 20, 2025

Choose a reason for hiding this comment

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

Do we need both msg_id and rfc724_mid in this table? rfc724_mid can be obtained from msg_id.
EDIT: Got it, msg_id is 0 when rows are inserted to download in fetch_new_msg_batch(). But UNIQUE(rfc724_mid) may still make sense.

EDIT: Added Make {download,available_post_msgs}.rfc724_mid columns PRIMARY KEY

* - `download_limit` = Messages up to this number of bytes are downloaded automatically.
* For larger messages, only the header is downloaded and a placeholder is shown.
* For messages with large attachments, two messages are sent:
* a Pre-Message containing metadata and a Post-Message containing the attachment.
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Full message" was a better term, "post-message" is literally "smth going after the message". And the full message should contain metadata as well, but the documentation doesn't say that

Copy link
Collaborator

Choose a reason for hiding this comment

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

We know "post-" message is technically wrong, but it is unambiguous - nobody else is going to call anything else a "post-message".

Copy link
Collaborator

@iequidoo iequidoo Jan 4, 2026

Choose a reason for hiding this comment

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

I think "full message" wasn't a good suggestion because it can also be applied to "normal" small messages. I'd say "big message" is a good term, and Chat-Is-Big-Message also sounds good.

EDIT: Still need to improve the documentation here... Done.

Comment on lines +737 to +732
uids_fetch.push(uid);
uid_message_ids.insert(uid, message_id);
Copy link
Collaborator

@iequidoo iequidoo Dec 27, 2025

Choose a reason for hiding this comment

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

                    if download_limit.is_none_or(|download_limit| size <= download_limit) {
                        uids_fetch.push(uid);
                        uid_message_ids.insert(uid, message_id);
                    } else {
                        download_later.push(message_id.clone());
                        largest_uid_skipped = Some(uid);
                    }

Maybe do smth like this here? This way pre-messages should still be downloaded immediately and big emails are downloaded later to speed up downloading of pre-messages and other small messages.

I've chacked that JSON-RPC tests work with this suggestion.

@iequidoo

This comment was marked as resolved.

@iequidoo iequidoo force-pushed the pre-messages branch 2 times, most recently from 4a119fc to 84ce946 Compare December 30, 2025 04:30
@iequidoo

This comment was marked as resolved.

@iequidoo

This comment was marked as resolved.

- Remove partial downloads (remove creation of the stub messages) (#7373)
- Remove "Download maximum available until" and remove stock string `DC_STR_DOWNLOAD_AVAILABILITY` (#7369)
- Send pre-message on messages with large attachments (#7410)
- Pre messages can now get read receipts (#7433)

Co-authored-by: Hocuri <[email protected]>
Co-authored-by: iequidoo <[email protected]>
Hocuri and others added 6 commits January 2, 2026 17:01
…essage before

There is a bug in pre-messages:
- A pre-message adds an entry to the `msgs` table with the `rfc724_mid` of the post-message
- If the pre-message and post-message are fetched in separate cycles:
  - `prefetch_should_download()` returns false, because `rfc724_mid_exists()` returns something
  - so, the message is not added to `download_later`, and never automatically downloaded.
…e-messages modify group members

There are no partial messages anymore, so i have no idea what else to check.
Also rename pre_message_is_downloaded_for() to msg_is_downloaded_for(). It's also used to check if a
post-message is downloaded.
It currently fails because pre-messages aren't deleted on IMAP.
Hyphen shouldn't be surrounded by spaces in general.
…th pre-message ones

When inserting pre-message checks in the middle, if they evaluate to false, the remaining checks
aren't performed. While this may be correct currently, it's hard to maintain. Better move the
pre-message checks into a separate block.
link2xt and others added 2 commits January 3, 2026 20:43
…_pre_message()

Now it goes before `scan_folders()`. Scanning folders isn't that important, it's even debounced to
once per minute. Before, `download_msgs()` even preceded the whole `fetch_idle()`.
@iequidoo

This comment was marked as resolved.

It's the post-message metadata by its nature and it's even put into the Chat-Post-Message-Metadata
header.
@iequidoo
Copy link
Collaborator

iequidoo commented Jan 4, 2026

https://github.com/chatmail/core/actions/runs/20696010931/job/59411461313?pr=7371
14 CFFI Python tests failed this way:

    def test_status(acfactory):
        """Test that status is transferred over the network."""
>       ac1, ac2 = acfactory.get_online_accounts(2)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_1_online.py:1200: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/py/lib/python3.14/site-packages/deltachat/testplugin.py:543: in get_online_accounts
    accounts = [self.new_online_configuring_account(cache=True) for i in range(num)]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/py/lib/python3.14/site-packages/deltachat/testplugin.py:515: in new_online_configuring_account
    self._acsetup.add_configured(ac)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <deltachat.testplugin.ACSetup object at 0x7f5398a253b0>
account = <Account path=/tmp/pytest-of-runner/pytest-0/popen-gw3/test_status0/ac2/dc.db>

    def add_configured(self, account):
        """add an already configured account."""
>       assert account.is_configured()
E       assert False
E        +  where False = is_configured()
E        +    where is_configured = <Account path=/tmp/pytest-of-runner/pytest-0/popen-gw3/test_status0/ac2/dc.db>.is_configured

.tox/py/lib/python3.14/site-packages/deltachat/testplugin.py:294: AssertionError
----------------------------- Captured stdout call -----------------------------
CACHE HIT for ci-sdkjgf@ci-chatmail.testrun.org
[acsetup] 0.014 added already configured account <Account path=/tmp/pytest-of-runner/pytest-0/popen-gw3/test_status0/ac1/dc.db> ci-sdkjgf@ci-chatmail.testrun.org
CACHE HIT for ci-zdcpw2@ci-chatmail.testrun.org

It's the first time i see this, probably it just makes sense to port all tests to JSON-RPC.

@iequidoo iequidoo marked this pull request as ready for review January 4, 2026 19:44
@iequidoo

This comment was marked as resolved.

@iequidoo
Copy link
Collaborator

iequidoo commented Jan 4, 2026

Btw, TZ=0 DCC_MIME_DEBUG=1 RUST_BACKTRACE=1 RUST_LOG=trace cargo nextest run --locked --no-fail-fast build time increased for me by ~15.4% here as compared to main. Tests run time almost hasn't changed however. Would be good to find the source of this pessimization. rustc 1.92.0.
...
Have made more experiments. Min. build time, pre-messages vs main: +3.1%. Pre-messages vs pre-messages with commented out tests using include_bytes! (6 tests total): +1.65%. So maybe the pessimization was subjective. But maybe we should avoid include_bytes!, +1.65% looks significant.

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.

[Tracking Issue] Pre-Messages

5 participants