Repository navigation
feat(platform): triage the Inbox and draft replies in the mail packs - #4036
Conversation
The three inbox triage packs read the raw mailbox and wrote a digest into the run's JSON: ids nobody could open, no cursor, nothing drafted, nobody told. They now work on the Inbox the sync packs fill. conversation.list_untriaged hands a pack the open threads of one mail connector whose newest message — by arrival, seq — is the customer's and newer than the thread's triage stamp: subject, contact, the message as text (the ingest's plain part, else the HTML stripped, 4000 chars) and the Inbox link. The model judges each one (reply / no_reply, priority, one reason); conversation.record_triage stamps the verdict on metadata.triage and sets the priority where no person has, so the thread is listed again only when the customer writes again, however old that message's Date header is. For every thread that needs an answer a second model call drafts one and conversation.draft_reply leaves it in the thread as the pending message a person sends. The three packs stay one document with the connector substituted; their own tests walk the whole lane against the mocks. Docs EN/DE/FR, the manifests' descriptions in three languages, the manual box CONV-F37, and a backend:integration lane on the real schema — listing, stamp, kept priority, and the seq cursor surfacing a late-ingested older message. An organization created before this change keeps its deployed digest versions; the new document lands as a new version through the editor or in a new organization.
Live proof (dev stack,
|
The reading pane keys a drafted reply on pendingApproval._id — the 0.4
approval shape the frontend contract declares — and suppresses the seed
when that id equals the draft it just replaced. loadPendingApprovals
handed the panel the raw {id, metadata} row, so _id was undefined, the
comparison held against an absent replacedApprovalId, and no drafted
reply ever rendered: the first live Inbox triage run left a pending
draft the thread did not show.
The newest pending approval now rides onto the item as an ApprovalItem
(_id, _creationTime, status, resource, priority, metadata, the optional
fields only when set), and the list projection test pins that shape.
|
Follow-up fix in this PR — the first live draft did not show in the thread. Root cause: |
The reading pane wrote a drafted reply straight into the composer, so a person could not tell what they had typed from what a model proposed — and the editor persisted the proposal as their own local draft. The pending approval now renders as a Suggested reply card above the composer: a labelled region with the proposal and two decisions. Put in editor hands the text to the composer through the one-time seed the undo lane already uses and leaves a status line; Discard rejects the approval through the approvals door and refreshes the thread, so the triage pack does not propose on it again until the customer writes again. The composer is never seeded on the person's behalf. Catalogs EN/DE/FR, the built-in automations guide in three locales, CONV-F13 and the coverage register updated; component tests for the card and the panel's two decisions.
|
Suggested-reply card (in this PR, by request) — an automation's drafted reply used to be written straight into the composer, indistinguishable from what the person typed (and persisted as their local draft). It now renders above the composer as a labelled Suggested reply region with Put in editor / Discard; the composer is never seeded on the person's behalf. Put in editor goes through the one-time seed the undo lane already uses and leaves a status line; Discard rejects the approval through the existing Also in this PR: the drafting prompt now keeps greeting, body and sign-off in the customer's language (it used to demand an English "Best regards"). |
Why
The three Triage the … inbox packs read the raw mailbox and wrote a digest into the run's JSON: Gmail ids nobody could open, no cursor (the same 25 newest mails re-judged every six hours), nothing drafted, nobody told. After #4034 the rows were at least populated; the pack was still a demo.
What
They now work on the Inbox the sync packs fill — one document for Gmail, Outlook and IMAP, connector substituted (
packs.test.tstrio rule holds).conversation.list_untriaged(new native,backend/domains/conversations/triage.ts): the open threads of one mail connector whose newest message — by arrival (seq) — is the customer's and newer than the thread's triage stamp. Each row: subject, contact, the message as text (the ingest's plain part, else HTML stripped, 4000-char cap), unread count, assigned, the Inbox link. Newest first, ≤100.triage(llm, skipped when nothing waits): one verdict per thread —action: reply | no_reply,priority, one-sentencereason— plus a summary.conversation.record_triage(new native): stampsmetadata.triage {at, seq, action, priority, reason, runId}and setspriorityonly where none is set (a person's choice is never overwritten). The stamp'sseqis the cursor: a thread is listed again only when a message lands after it — however old that message's own Date header is (a sync pass ingests mail minutes after it was sent; a wall-clock cursor stepped over it for good, which the integration lane caught in its first run).due(transform): thereplyverdicts joined back onto the listing, so a verdict naming an id the pack never read is dropped.draft(llm,forEach) →propose(conversation.draft_reply,forEach,onError: continue): one drafted reply per thread that needs one, left as the pending message a person sends (CONV-F13's lane; a thread already holding a pending draft keeps it,created: false).read,summary,recorded,needsReply[](with Inbox links),drafted[].Also: connector contract + mocks (
conversation/connector.yml), native wiring + tests, docsbuiltin.mdEN/DE/FR, manifests' descriptions in three languages, manual boxCONV-F37, coverage row, and acheckInboxTriageLaneinbackend:integration.Not in scope: a bell notification for the digest (dropped by request), an Inbox badge for the triage verdict, a REST twin.
Proof
packs.test.ts(each pack's own tests walk list → judge → record → draft → draft_reply against the mocks),natives/index.test.ts,registry.test.ts,triage.test.ts, the integration-scope guard: green. Platform typecheck, oxlint,lint:manual,lint:links,@tale/docs test(locale parity): green.ITEST_LANES=checkInboxTriageLane backend:integrationon a throwaway tale-db + MinIO: 20/20 — listing (waiting + person-prioritized threads in, team-answered-last and closed out, HTML stripped, link shape), stamp (verdict,runId, priority set on one and kepturgenton the other, unknown id reported), and the seq cursor (nothing after the stamp; a customer message dated an hour earlier but ingested after it surfaces the thread again).