From 08f5e4561dd9f7c9614883abcd5c1d256705802a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Thu, 23 Jul 2026 18:24:13 +0000 Subject: [PATCH] todo: mark Gmail-style operators done; note OR/grouping as remaining Co-Authored-By: Claude Opus 4.8 --- TODO.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/TODO.md b/TODO.md index 76644622..ecf2e14d 100644 --- a/TODO.md +++ b/TODO.md @@ -27,17 +27,15 @@ Deferred work. Context: Officer is collapsing from multi-tenant / open-source-re ## Email -- [ ] **Gmail-style search operators.** Extend the FTS5 search (`/email/search`, `searchEmails` + - `toFtsQuery` in `api/email/email-db.ts`) to parse structured operators like `from:`, `to:`, - `subject:`, `has:attachment`, `label:`, `before:`/`after:` (dates), `is:unread`, quoted phrases, - and `OR`. Today `toFtsQuery` just does per-term prefix-AND across all columns. - Approach: split the query into (a) **field-scoped text** → FTS5 column filters (the `emails_fts` - table already has named columns `subject`/`sender`/`recipients`/`snippet`/`body`, so - `subject:foo` → `{subject}:"foo"*` in the MATCH; `from:x` → the `sender` column) and (b) - **structured filters** applied as SQL `WHERE` alongside the MATCH — `has:attachment` → - `attachment_count > 0`, `before:/after:` → `date` range, `is:unread` → `read = 0`, `label:` → - `labels LIKE`. Free text stays full-text. Frontend: keep the single search box (operators are - typed inline, Gmail-style) — no UI change needed beyond maybe a hint/legend. +- [x] **Gmail-style search operators** (done 2026-07-24, `0e5b91e`). `parseEmailQuery` + + `searchEmails` in `api/email/email-db.ts` parse: `from:`/`to:`/`subject:`/`body:` → FTS5 column + filters; `has:attachment`, `is:unread`/`is:read`, `label:X`, `before:`/`after:YYYY-MM-DD` → SQL + `WHERE` on `emails`; quoted values → exact phrases; free text → prefix-AND full-text; unknown + `op:val` falls back to free text. Structured-filters-only queries skip the FTS join. Validated + on the real 18k-mail DB. Search box placeholder hints at operators. + - [ ] **Remaining:** `OR` and parenthesised grouping (currently everything is ANDed). Would need a + real boolean parser instead of the flat tokenizer. Also consider `in:sent/inbox/spam/trash` + (folder scope) and relative dates (`newer_than:7d`). ## Known bugs