Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Notable changes to Swarmail. Versions follow [semantic versioning](https://semve
- `swarmail who` asks git about each running T3 thread directory once instead of once per thread. With about 800
running threads in 149 directories it took 0.3 s instead of 1.6 s.

- `fetch_inbox` and `fetch_session_inbox` no longer read each message body from storage when `include_bodies` is off,
which is the default. A page of 20 messages took 48 µs instead of 57 µs with 2 KB bodies and 52 µs instead of 82 µs
with 17 KB bodies.

## 0.5.2 - 2026-10-09

- Require agents to record whole-session closeouts and retire their own project
Expand Down
9 changes: 7 additions & 2 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,12 +678,17 @@ export class MailStore {
};
}

/** Bodies are the one large column; read them only for a page that includes them. */
private bodyColumn(a: Args): string {
return a.include_bodies ? "m.body_md" : "NULL AS body_md";
}

inbox(p: Project, who: Agent, a: Args, markRead: boolean) {
const now = nowUs();
const rows = this.db
.query<Row, any[]>(
`SELECT m.id, m.project_id, m.sender_id, m.thread_id, m.topic, m.subject, m.importance, m.notification_policy, m.revision, m.ack_required,
s.name AS "from", m.sender_location, m.created_ts, r.read_ts, r.ack_ts, r.kind, m.body_md
s.name AS "from", m.sender_location, m.created_ts, r.read_ts, r.ack_ts, r.kind, ${this.bodyColumn(a)}
FROM message_recipients r JOIN messages m ON m.id = r.message_id JOIN agents s ON s.id = m.sender_id
WHERE r.agent_id = ?1 AND r.withdrawn_ts IS NULL AND (?2 = 0 OR r.read_ts IS NULL) AND (?3 = 0 OR m.importance IN ('high', 'urgent'))
AND r.created_ts > ?4 AND (?5 IS NULL OR m.topic = ?5)
Expand Down Expand Up @@ -729,7 +734,7 @@ export class MailStore {
const rows = this.db
.query<Row, any[]>(`
SELECT m.id, m.thread_id, m.subject, m.importance, m.notification_policy, m.revision,
m.ack_required, m.created_ts, m.body_md, s.name AS "from",
m.ack_required, m.created_ts, ${this.bodyColumn(a)}, s.name AS "from",
r.read_ts, r.ack_ts, a.id AS recipient_id, a.name AS agent_name,
p.human_key AS project_key
FROM agents a JOIN projects p ON p.id = a.project_id
Expand Down
Loading