Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7509c90
E00: freeze the mail.exportEml contract, capabilities, and limits
latentoperator Sep 29, 2026
b730830
E00: record the confirmed export decisions
latentoperator Sep 29, 2026
19d8a79
E01: retrieve exact original IMAP message bytes
latentoperator Sep 29, 2026
5aa0002
E02: save the export safely and expose mail.exportEml
latentoperator Sep 29, 2026
31f387f
E03: message-menu export and the Ctrl+Shift+S binding
latentoperator Sep 29, 2026
e5ad88c
Fix raw export retrieval to reject ambiguous IMAP bodies
latentoperator Sep 29, 2026
7f8b9e7
Enforce the frozen export concurrency, deadline and cancellation cont…
latentoperator Sep 29, 2026
d5f957e
Route and gate message exports at one dispatch boundary
latentoperator Sep 29, 2026
e045e1e
Test raw export parsing without holding pooled connections
latentoperator Sep 29, 2026
1d302c7
Keep the export routing test independent of test order
latentoperator Sep 29, 2026
f462a0b
E03: require literal-provenance IMAP bodies for export
latentoperator Sep 29, 2026
92feff5
E03: enforce the export deadline, duplicate refusal and anchored storage
latentoperator Sep 29, 2026
412c888
E03: document cooperative cancellation and test the drop path (R3)
latentoperator Sep 29, 2026
02dd393
Fix export cancellation, collision deadlines and size admission
latentoperator Sep 29, 2026
f47e2de
docs: Record the tested export fix candidate
latentoperator Sep 29, 2026
066c744
fix: Cancel disconnected requests under queue pressure
latentoperator Sep 30, 2026
7c87b4c
docs: Record export review fixes and process checks
latentoperator Sep 30, 2026
cc95b2d
fix: Observe closed output pipes on macOS
latentoperator Sep 30, 2026
809adaf
docs: Record macOS pipe observer correction
latentoperator Sep 30, 2026
8dd996e
Merge remote-tracking branch 'origin/main' into task/E03-export-ui
latentoperator Sep 30, 2026
00453f6
Drop internal task references from source comments
latentoperator Sep 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 74 additions & 14 deletions backend-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"mail.read",
"mail.act",
"mail.send",
"mail.exportEml",
"mail.watch",
"mail.unwatch",
"mail.check",
Expand Down Expand Up @@ -189,47 +190,84 @@
"params": {
"query": "search:ALL",
"continuation": "expired-snapshot",
"settings": {"username": "synthetic", "imapHost": "imap.example.invalid", "imapPort": 993},
"settings": {
"username": "synthetic",
"imapHost": "imap.example.invalid",
"imapPort": 993
},
"credential": "synthetic:secret"
},
"errorCode": -32000,
"equals": {"message": "imap_search_expired"}
"equals": {
"message": "imap_search_expired"
}
},
{
"name": "IMAP account search refuses a malformed page cursor",
"method": "imap.list",
"params": {
"query": "search:ALL",
"pageToken": "not-a-page-cursor",
"settings": {"username": "synthetic", "imapHost": "imap.example.invalid", "imapPort": 993},
"settings": {
"username": "synthetic",
"imapHost": "imap.example.invalid",
"imapPort": 993
},
"credential": "synthetic:secret"
},
"errorCode": -32602,
"equals": {"message": "Invalid params"}
"equals": {
"message": "Invalid params"
}
},
{
"name": "IMAP text search includes archived mail",
"method": "providers.resolve",
"params": {"provider": "imap", "operation": "query", "search": "subject:invoice"},
"equals": {"value": "search:SUBJECT \"invoice\""}
"params": {
"provider": "imap",
"operation": "query",
"search": "subject:invoice"
},
"equals": {
"value": "search:SUBJECT \"invoice\""
}
},
{
"name": "Outlook text search includes archived mail",
"method": "providers.resolve",
"params": {"provider": "outlook", "operation": "query", "search": "invoice"},
"equals": {"value": "search:TEXT \"invoice\""}
"params": {
"provider": "outlook",
"operation": "query",
"search": "invoice"
},
"equals": {
"value": "search:TEXT \"invoice\""
}
},
{
"name": "IMAP address search includes archived mail",
"method": "providers.resolve",
"params": {"provider": "imap", "operation": "addressQuery", "field": "from", "value": "ada@example.org"},
"equals": {"value": "search:FROM \"ada@example.org\""}
"params": {
"provider": "imap",
"operation": "addressQuery",
"field": "from",
"value": "ada@example.org"
},
"equals": {
"value": "search:FROM \"ada@example.org\""
}
},
{
"name": "IMAP All mail resolves to account-wide listing",
"method": "providers.resolve",
"params": {"provider": "imap", "operation": "query", "mailbox": "all"},
"equals": {"value": "search:ALL"}
"params": {
"provider": "imap",
"operation": "query",
"mailbox": "all"
},
"equals": {
"value": "search:ALL"
}
},
{
"name": "iCloud request refuses an external credential origin",
Expand Down Expand Up @@ -807,10 +845,32 @@
"types": {
"ticket": "string"
}
},
{
"name": "mail.exportEml refuses an unknown account without provider work",
"method": "mail.exportEml",
"params": {
"account": "imap:missing@example.invalid",
"id": "1:INBOX"
},
"errorCode": -32000,
"equals": {
"message": "mail_account_unknown"
}
}
],
"unreleased": {
"methods": [],
"cases": ["IMAP All mail resolves to account-wide listing", "IMAP text search includes archived mail", "Outlook text search includes archived mail", "IMAP address search includes archived mail", "IMAP account search refuses an expired work continuation", "IMAP account search refuses a malformed page cursor"]
"methods": [
"mail.exportEml"
],
"cases": [
"IMAP All mail resolves to account-wide listing",
"IMAP text search includes archived mail",
"Outlook text search includes archived mail",
"IMAP address search includes archived mail",
"IMAP account search refuses an expired work continuation",
"IMAP account search refuses a malformed page cursor",
"mail.exportEml refuses an unknown account without provider work"
]
}
}
1 change: 1 addition & 0 deletions docs/KEYS.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ used to exist, and they had.
| `archive` | `e` | mail | Archive |
| `trash` | `d` | mail | Move to trash |
| `star` | `s` | mail | Star or unstar |
| `exportEml` | `Ctrl+Shift+S` | mail | Save as .eml |
| `moveToLabel` | `v` | mail | Move to |
| `markRead` | `Shift+I` | mail | Mark read |
| `markUnread` | `Shift+U` | mail | Mark unread |
Expand Down
44 changes: 43 additions & 1 deletion src/backend/mail.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
use super::Session;
use crate::mail::{ActRequest, ListRequest, Provider, ReadRequest, SendRequest};
use crate::mail::{ActRequest, ExportRequest, ListRequest, Provider, ReadRequest, SendRequest};
use serde_json::{Value, json};
use std::{future::Future, pin::Pin};

#[cfg(test)]
#[path = "mail_action_tests.rs"]
mod action_tests;

/// Supplies the IMAP raw-message retrieval to the export service. Credentials are resolved
/// by the IMAP layer from the account id, as every other provider call does, so
/// no secret passes through the export path.
struct ProviderExport;

impl crate::mail::export::ExportAdapter for ProviderExport {
fn raw<'a>(
&'a self,
account: &'a crate::mail::Account,
id: &'a str,
request_token: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Value, &'static str>> + Send + 'a>> {
Box::pin(async move {
let (uid, folder) = crate::providers::imap::message_id(id)?;
// The token names this fetch in the IMAP cancel registry, so
// dropping the export (or `imap.cancel`) stops the socket read.
let params = json!({
"accountId": account.id,
"folder": folder,
"uid": uid,
"requestToken": request_token,
});
imap_call("imap.rawMessage", &params).await
})
}
}

struct ProviderList<'a> {
session: &'a Session,
}
Expand Down Expand Up @@ -364,6 +391,21 @@ impl Session {
)
.await
}
"mail.exportEml" => {
let request = ExportRequest::try_from(params)?;
let refusals = crate::account::refusals_readonly(&request.account.id)?;
let downloads = crate::platform::dirs::AppDirs::discover()?.downloads;
let control = crate::mail::export::ExportControl::new();
crate::mail::export::export_with(
request,
&ProviderExport,
&downloads,
&refusals,
crate::mail::export::process_limits(),
&control,
)
.await
}
_ => Err("unknown_method"),
}
}
Expand Down
1 change: 1 addition & 0 deletions src/backend/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub const ALL: &[&str] = &[
"mail.read",
"mail.act",
"mail.send",
"mail.exportEml",
"mail.watch",
"mail.unwatch",
"mail.check",
Expand Down
5 changes: 4 additions & 1 deletion src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ impl Session {
if method.starts_with("agent.") {
return Err("unknown_method");
}
if matches!(method, "mail.list" | "mail.read" | "mail.act" | "mail.send") {
if matches!(
method,
"mail.list" | "mail.read" | "mail.act" | "mail.send" | "mail.exportEml"
) {
return Box::pin(self.mail_call(method, params)).await;
}
if matches!(method, "system.info" | "system.quit" | "providers.list") {
Expand Down
Loading
Loading