Repository navigation
fix(platform): preserve drafts during session recovery - #3569
Conversation
Only 400 ORG_SLUG_REQUIRED carried data.organizations. A key holder in several organizations who mistyped X-Organization-Slug (404 ORG_SLUG_INVALID) or named a foreign one (403 ORG_FORBIDDEN) learned what was wrong but not what to send, and GET /api/v1/me sits behind the same header. The getting-started page already promised the list on both. listSelectableOrganizations (every membership that is not disabled and has a slug, oldest first) now backs every refusal the resolver throws and the door's own two: the malformed-header 404, which still never looks the value up, and the 403 for a membership removed mid-request. Contract 3.1.0; the OpenAPI descriptions, the organization-selection table (EN/DE/FR), the MCP and tutorial pages and the manual registers say so. A new backend:integration lane, checkOrgSlugRefusals, sends a mistyped, a malformed, a foreign and a disabled slug with a two-org key.
An email's body reached no index: the covering note that explains an attachment (the role an applicant names, the order a complaint is about) was invisible to every retrieval leg. Inbound email bodies now index under a message ref and answer the chat assistant, behind the same assignment privacy as an emailed attachment. - lib/knowledge/message-ref.ts: encoder and parser (`msg:<message id>`), the LIKE pattern, and the one definition of what the corpus holds: inbound `email` messages (`isIndexedMessage`). - Ingest: `addMessageToConversation` queues `rag.index_message` in the insert's own transaction for a non-empty inbound email; the job reads an HTML body down to text (html-to-text), heads its chunks with subject and sender, stamps the conversation id, runs the secret scan and PII policy, and ends quietly on refusals no retry changes. Its own queue, so a mailbox backlog never stands in front of an upload. - Gate: the `msg:` deny becomes a branch decided by the message's conversation (`conversationAssignmentAllows`, a live lifecycle, not spam), resolved with the attachments' conversations in one read, and only for a door that asks (`includeConversationMessages`: the chat tools). The corpus pre-filter excludes message rows for every other door, so the sandbox bridge, the MCP door and REST never see a body they do not wrap. - Chat: a body hit is a `conversation` row citing its conversation, its passage wrapped as mail; `rag_fetch` reads the whole body under the inbox role. The timeline never shows a raw `msg:` id, and no source card offers a file preview for one. - Dedup: an email body never clones another row's chunks and nothing clones from one (the header names a correspondent another reader may not see). - Cascade: liveness is the inbound message row; `deleteConversation` queues the release of its bodies, the retention window releases them before it purges (a failed release keeps the conversation), and the corpus reconcile walks message refs apart from blob refs from a random pivot. - Real-Postgres proof: the `checkInboundEmailBodies` integration lane. - Docs (EN/DE/FR), manual boxes CHAT-F49/CHAT-B16, the automation register and the knowledge ledger's stale PENDING notes (queue-on-bind landed in #3225). Refs #3015
Members showed 10 rows, credentials and skills 25, the governance lists 25 per server page and the trash the server's 50, while Teams and API keys showed 20 through their own literals. Every settings list now takes DEFAULT_LIST_PAGE_SIZE. The audit and error logs keep 30 as the one documented exception (LOG_PAGE_SIZE, with its reason beside it). Teams and API keys put their create button in DataTable's actionMenu escape hatch through two wrapper components. They now pass addAction like Members and the credential tables, with the create dialog mounted beside the table. On API keys, which has no search box, the empty state also carried a hand-made Create button under the toolbar's own, so an empty list offered two; addAction moves the one button into the empty state, and the API docs link sits under the table in every state. list-conventions.test.ts guards both rules across the settings sources.
0017 ported the 0.4 FIFO admission-ticket lane and the workflow re-attach checkpoints, but no 0.5 caller ever wired either, and since v0.5.9 no image reads or writes them. Migration 0123 drops both, and the deferral note in the session substrate goes with it. A backend:integration lane reads the dropped names from 0123, checks each is a table 0017 created, and asserts none is left in the migrated schema.
A schedule whose automation fails the same way at every occurrence used to fire forever: every run failed, spent what it could and told nobody. finishRun now keeps a failure streak per trigger, in the transaction that lands a run a trigger started (`trigger:<id>`): - a success resets it; a failure with a code the next occurrence would repeat (node_error, connector_error, llm_output_invalid, auth_error, missing_api_key, credit_exhausted, model_not_found) counts; transient codes, unclassified failures and cancels neither count nor reset; - runs started before the trigger was last saved never count, and every save resets the streak; - the fifth permanent failure in a row turns an enabled schedule off (enabled=false, new skip reason `paused_after_failures`), writes an `automation.trigger.paused` audit row and notifies each owner and admin with the revived `automation_failed` type (bell + email, gated by the `automation_alerts` preference, opening the automation's General tab); - webhook and event triggers keep a streak but are never paused, since a paused one would drop the deliveries and events that arrive meanwhile; - the bookkeeping rides a savepoint so it can never leave a run unfinished, and the notice a nested one so a failed bell keeps the pause. Migration 0123 adds the streak columns (consecutive_failures, last_failed_at_ms, last_failure_code, last_failed_run_id) and widens the skip-reason CHECK. The Trigger section shows the pause, the streak, the last failure's code and a link to its run; saving the trigger clears the pause and marks the notices read. Settings > Notifications offers Automation alerts to owners and admins again. REST contract 3.1.0 adds the streak to `Trigger` and the new reason to `lastSkipReason`; the MCP trigger view carries the same fields. Docs (EN/DE/FR), manual boxes and a real-Postgres lane (`checkTriggerPauseAfterFailures`) cover it. Refs #3092
About 190 app doors answered a body their schema refused with a bare
`{ error: 'invalid body' }`: the dialog could only say "invalid body",
and the error report carried the same opaque code, so nobody could tell
which field the form had let through.
Every door now answers through `backend/lib/invalid-body-response.ts`:
the same `invalid body` code, a `field: reason` message and the issues
under `data.issues`. `invalidBodyIssuesResponse` covers a refusal no
schema raised (a body that is not JSON, the automation save's missing
`document`). An email with neither body nor files is refused at
`content`. A guard test fails any bare literal left under `backend/`.
The caps a form has to mirror now live where the app can read them:
the contact caps beside the contact patterns in `lib/shared`, the
object-storage connection caps in its shared schema, and the Postgres
host rule and password cap in `@tale/shared/schemas/knowledge`.
The UI evaluations kept hitting `invalid body` on Products, Contacts and Data residency (TALE-84, TALE-162, TALE-103): each form let through a value the door refuses. - Contacts: the form trims and caps Name (300), Email (320, at most 64 characters before the `@`), Phone (50) and Locale (20) with the shared caps, and both dialogs put a refused body's reason on the toast. - Products: a pasted image address must be an absolute http(s) URL (or the app path an upload returned); the error sits under Image URL. - Data residency: Test connection checks the fields the way Save does and names what it would refuse instead of sending it; required fields are judged trimmed, as they are sent, and every field has the door's length cap. - The default mutation and action toasts (and the task toasts) show an `invalid body` refusal's field-naming sentence instead of "Try again". New `products.edit.validation.imageUrl` in en, de and fr; the product and self-hosted data-residency docs say what the forms check, in all three languages. Manual boxes KNOW-B13 and DATA-B8, with the owning specs in the automation register.
prepareDocument ran the organization's PII policy over the body alone, then prepended the header (title or filename) to every chunk unscrubbed. An email body's header names its sender, so under a mask policy the address was still embedded, stored in chunk_content, keyword-indexed and kept as documents.filename; under block, PII in the header never refused the document. The header and the stored name now go through the same decision as the text, for every lane: mask masks both, block refuses when either matches. A header the policy rewrote joins the content hash, so a policy switched on re-indexes a body it found nothing in; an untouched header leaves every stored hash where it was.
A chat caller who reads the inbox asked the corpus for email bodies, and the SQL pre-filter admitted every body org-wide in the same candidate pool as the documents; assignment privacy was decided only afterwards by the admission re-check. In a shared inbox, where an unassigned conversation is admin triage, a member's query filled each leg's pool with bodies the re-check then refused, and a document they could read ranked just behind them never came back. The documents reader now searches bodies as a partition of their own, each leg with its own candidate pool, and merges the two lists by the leg's score without cutting either: a refused body can only displace another body. A conversation narrow searches bodies alone (onlyEmailBodies), and one the role cannot read runs no embedding and no query at all.
Which email bodies the corpus holds, and how each lane lets them go: - Only mail a connector delivered indexes (connector_name). A member logging a message by hand may say isCustomer and bring its own from and subject, and must never index as a customer's mail. - A spam verdict releases a conversation's bodies (liveness reads a spam conversation's messages as dead) and lifting it queues them for indexing again, from the PATCH door and the bulk verb alike. Mail that lands on a conversation already marked spam is never queued, and the indexer skips it, so junk is never sent to the embedding provider. - The retention window queues the release in the transaction that deletes the conversations, as deleteConversation does, instead of releasing synchronously and stranding the conversation when the knowledge database cannot be reached. The job runs after the commit, so a body a late job indexed is released too. - The indexer's secret scan reads the chunk header with the body, and a test proves the organization's PII policy reaches it. The reads live in domains/conversations/message-corpus.ts; the integration lane now proves the PII mask on the header, chunks and stored name, and the spam release and re-index, on real Postgres.
Inbound email indexing waits for the organization's embedding limiter beside file batches in arrival order: its own pg-boss queue keeps a mailbox backlog out of rag.index_file, not out of the limiter. The data-residency page (EN/DE/FR) now names it among the work sharing maxConcurrentRequests, and the enqueue and queue comments say where the order holds and why email gets no lower limiter priority. The knowledge ledger says a mailbox connected after this change indexes the history its first sync imports, and records the connector marker, the spam release and the queued retention release; CHAT-B16 and the automation register follow.
The sandbox drift reconcile settled every compute-holding row whose container was gone as destroyed, pinned or not, and nothing ever pushed a pin back to the spawner, which forgets it whenever a container goes (a create always starts unpinned). A pinned workspace that lost its container (host restart, a removed container) was dropped from the Sandboxes page. reconcileSession now reads the row fresh after the liveness probe. A pinned, compute-holding row has its pin re-asserted when the session is alive, and when it is gone the session is recreated through the spawner's create path under the same id, organization and stored profile (the spawner re-attaches the workspace it preserved under the id) and re-pinned, never settled. A duplicate create is re-pinned, a refused pin or failed create leaves the row for the next visit, and a pinned row destroyed or hibernated since the batch is left alone. Unpinned phantoms heal as before. The watchdog spawner gains the pin and create verbs, the sweep counts a recreate apart from a heal, the real-Postgres watchdog lane covers a pinned phantom and a live pinned row, SET-F62 carries the manual check, and the Sandboxes admin guide says a pinned workspace comes back.
Three open changes each scaffolded 0123, so whichever lands later renumbers its file. Resolving the drop migration by its slug keeps that a pure rename, with no edit to the proof lane.
The workspace-tool bridge kept only the code of a domain refusal. An agent's task_create with a description over 20,000 code units or a label over 50 came back as "TASK_DESCRIPTION_INVALID: the domain refused these arguments.", so the model could not tell which limit it broke. The domain threw one "Invalid title" for an empty and an over-long title on the human create and edit paths, and the tasks app door dropped the domain's message altogether. - core/tasks/helpers.ts now holds the refusal sentences beside the limits. Each names the cap, the unit every cap is measured in (UTF-16 code units, where most emoji count as 2) and the length measured, never the value. validateTitle tells an empty title from an over-long one, and the description, label count, label name and comment caps are named. - toolResultFromError relays the domain's sentence beside the code, and nothing else from the refusal's payload. - The agent-comment writer moves into the coded write shim, so an over-long comment answers invalid_args instead of error. - workspace_status states every cap of task_create, task_comment and task_upsert_by_external_ref from the shared constants, in code units. - The tasks app door answers a domain refusal with its message, and an empty title on create reaches the domain instead of a bare invalid body. Closes #3155
#3519 landed 0123_project_agent_runs_mention_source.sql on main first, so the trigger failure streak takes the next free number.
finishRun audited the run (the org's audit-chain lock) and only then wrote the trigger row, the reverse of the order a producer that stamps an event trigger and then audits takes, e.g. a comment edit's comment.mentioned dispatch. The two could deadlock. finishRun now locks the trigger row first (lockTriggerForRunOutcome, in a savepoint, and only for the rows the streak will write), audits the run, then keeps the streak. A success that lands after its schedule paused (a run that overlapped the pause) no longer resets the streak: the paused schedule keeps the count that paused it until someone saves the trigger.
- deleteTrigger and deleteAutomationCascade mark the automation_failed notices of a paused schedule read, and only of a paused one. - The MCP trigger view selects and carries the failure streak, omitting a last failure there never was. - The real-Postgres lane reads the paused schedule back through listTriggers and checks that a success landing after the pause keeps the streak.
The Trigger section's View run always opened the organization's run route, even on a project's General tab, dropping the project breadcrumbs and sidebar. The project route now hands its projectId down and the link picks the project run route, as the run list does. The failure code and the streak lines use @tale/ui InlineCode and Text instead of hand-rolled copies.
Undoing a queued reply handed back its markdown only, and the panel seeded the composer only when there was some, so undoing an attachment-only reply restored nothing. The undo door now hands back the files the recalled send named (email and API lanes), the panel seeds the reply box with both, and a re-send names the same stored blobs instead of uploading them again. The restored draft seeds only the conversation it was undone in. The remove button on a file chip in the reply box had no accessible name (WCAG 4.1.2). It is named after the whole file name through the existing common.aria.removeNamed key (en, de, fr), with a visible focus ring. Manual boxes CONV-F33 and CONV-A8 with their automation row.
The governance pages' loaders skipped their policy reads only when the member context was already cached. On a cold deep link TanStack runs the dashboard loader, which starts that read, beside the page's, so nothing was cached yet and a member was asked for every admin-only policy the page's editors read, answered 403 each time. ensureGovernancePolicies now warms a policy any member may read at once and holds an admin-only one until the member context resolves, joining the dashboard's read in flight, so a member never asks for one. The member-readable set moves to @tale/shared/schemas/governance so the governance door and the loaders read one list.
Three gaps left open by the reviewer re-target (#3517): - Erasure stamped a review still waiting on the subject with the pseudonym, so it waited on nobody. The review pass now clears the designation first, hands each waiting review on through the chain a cleared designation takes (task creator, then project creator, the subject skipped in every slot) and rings the new reviewer as the system; only what still names the subject is pseudonymized after. - Changing or clearing the reviewer before In review left the previous designee's unread "You're the reviewer" heads-up ringing; it is now marked read when the designation moves. - A designee who cannot edit the project was stored and then routed past at mint. The designation is held to the same rule the gate resolves by (reviewerEligibility) and refused with 400 TASK_REVIEWER_NO_EDIT_ACCESS; the task dialog names the refusal with the picker's own hint. Manual boxes PROJ-F33, PROJ-F34 and PROJ-B9, their automation rows, the error-code row, and the data subject request docs (EN/DE/FR).
# Conflicts: # services/platform/app/features/conversations/components/inbox-upload-failure.browser.test.tsx
A run's delete clears it from the trigger that names it: the trigger's last_run_id and last_failed_run_id are ON DELETE SET NULL, so the delete writes the trigger row. The run door (deleteRunInTx) and the retention sweep did that before their audit row, the reverse of a landing run, which audits first and then keeps the trigger's failure streak. A run of the same trigger landing meanwhile deadlocked (40P01). The streak's savepoint lost, so the failure went uncounted and a failing schedule could miss its pause. Both removals now lock the runs' own rows, then the organization's audit chain (lockAuditChain), then delete. That is the order finishRun takes its run row, the chain and the trigger row in. The retention sweep selects its batch FOR UPDATE, takes the chain and deletes by id; an empty batch takes no chain. The lock-order lane gains both removals, held between the delete and the audit row. On the previous code both reported "deadlock detected" and a streak that did not move.
# Conflicts: # services/platform/tests/manual/reference/automation.md
# Conflicts: # services/platform/backend/domains/collab/service.test.ts # services/platform/backend/integration-check.ts # services/platform/tests/manual/readme.md
# Conflicts: # services/platform/tests/manual/readme.md
# Conflicts: # services/platform/tests/manual/readme.md
# Conflicts: # services/platform/tests/manual/readme.md
On a cold deep link the admin-only policies wait for the member-context read; when that read met the session door's 401 the rejection reached the route's preload warning, which the policy reads' own 401 never did. Read the raw-lane error the way the adapted one is read, so both are swallowed.
Main fixed checkOrganizationLifecycle on its own (842396a confirms every deletion after the rename with renamedNameA), and the merge that brought it into this branch kept that fix but left this branch's comment above a constant that no longer exists. Remove it; the lane's diff against main is now only the new checkDeletedOrgDoors registration.
There was a problem hiding this comment.
Rechecked the earlier P2 draft-loss concern at exact head 927a6b74b9b95f73b6d36e17a075048b97c972a8. The revised flow keeps the mounted dashboard and unregistered dialog drafts until the person explicitly chooses Sign in; Stay here, restoration in another tab, and stale checks during deliberate authentication transitions are covered. This addresses my earlier concern.
Fresh direct local run: 32/32 tests passed across session-lapse-drafts, use-session-lapse-redirect, session-transition-redirect, and dashboard, using this head’s frozen dependency lockfile. I reviewed the recovery/redirect implementation and its cancellation guards. React Doctor scanned 45 changed files and scored 80; its dashboard cleanup diagnostic is a false positive here (both scheduled timers share the cleared handle, async continuations check cancellation, and both unmount controls passed). The other diagnostics are login-flow complexity and sequential negative integration probes, not a newly confirmed blocker.
No new finding in this focused follow-up. I did not rerun a browser or the full repository suite, and some current-head CI checks were still queued/running at readback. This comment does not merge or deploy the PR.
A background request after session expiry could display the REST API's English guidance and hard-navigate away from unsaved dialog input. This change gives app refusals one localized session-ended message and keeps an already-open dashboard mounted until the person explicitly chooses to sign in.
Confirmed expiry opens a recovery dialog. Stay here preserves typed values and returns focus; a persistent notice lets the person reopen recovery. Repeated refusals share a check. Sign in rechecks the session before leaving, preserves the current route/query/hash for the return URL, and shows a retryable failure if confirmation cannot reach the server. A session restored in another tab refreshes the existing auth/user caches without dropping the draft or creating a request loop. Cold signed-out entry still follows the login path.
Intentional sign-out, idle expiry, password changes and two-factor token rotation keep ownership of their cleanup and navigation. Transition versions reject stale recheck results, and a cancelled native leave prompt permits recovery to resume. All refusal readers use the same mapping; API error codes and wire guidance remain unchanged.
EN/DE/FR messages and member documentation, the de-CH spelling override, manual auth cases and automated coverage are updated. The final review also preserves the other accepted PRs during integration; those land separately before this PR.
Validation:
A dormant tab still learns of expiry on its next request. Choosing Sign in intentionally leaves the current document; the recovery notice lets the person first retain work they need.