* fix: Include surrounding container in document mention emails
getNodeForMentionEmail only preserved tables and checkbox lists around a
mention; mentions inside bullet/numbered lists, blockquotes and notices were
returned as a bare paragraph with their structure stripped. Add those
containers so the snippet keeps its context.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor: Resolve mention position and walk ancestors for email snippet
Replace the top-down scan-and-guess over a block-node allowlist with a single
position resolve and an ancestor walk. Behaviour is unchanged — same outermost
container, minified to the child on the path to the mention — but extraction is
idiomatic ProseMirror and drops the redundant subtree traversals.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor: Size-bound mention email snippet, drop container special-casing
Replace the per-type container allowlist and minify logic with a single rule:
climb the mention's ancestor chain outward and keep the largest complete block
that still fits a character budget. This drops all special-casing, is robust to
new node types, and naturally bounds snippet size.
Semantics change accordingly — a small container is now shown whole (with its
sibling rows/items) rather than minified to the mention's child, degrading to an
inner block once the container overflows the budget. Tests updated to match.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat: Window mention email snippet to nearby list items
Lists can be long, so instead of including the whole list as the size-bounded
walk would, trim a surrounding list to the mentioned item plus one sibling on
either side. Uses the nearest list ancestor so nested lists show the items
closest to the mention. Non-list content keeps the size-bounded behaviour.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: Ensure mention in doc emails always include context
* PR feedback
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
An empty Notion table was converted to a schema-invalid table node with
no rows. Node.fromJSON accepts it, but Markdown serialization then crashed
in renderTable's node.child(0), surfacing only "Index 0 out of range for <>".
Drop empty tables in the Notion converter, and guard renderTable against
tables with no rows so any source is handled safely.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* Add composite (userId, createdAt) index for searches.list
The searches.list endpoint filters by userId/teamId and orders by
createdAt DESC, but search_queries only had single-column indexes. Since
a row is inserted on every search, the table grows large and the planner
must either fetch and sort a user's entire search history or scan the
createdAt index until enough matching rows are found — both proportional
to history size rather than page size.
Add a composite index on (userId, createdAt) so the query can seek
directly to the user's rows in createdAt order and stop after LIMIT rows.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wAHcneY9eV4fZtCBq8Ue3
* Drop redundant userId and unused createdAt indexes on search_queries
With the new (userId, createdAt) composite index in place, the
single-column userId index is fully redundant (covered as a leftmost
prefix) and the createdAt index is unused — no query orders or filters
by createdAt without also constraining userId. Dropping both removes
index-maintenance overhead on the high-write search_queries table. The
teamId index is kept for the team permanent deleter.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wAHcneY9eV4fZtCBq8Ue3
* Use CONCURRENTLY for search_queries index changes to avoid table locks
Switch the composite index creation and the redundant index drops to raw
CREATE/DROP INDEX CONCURRENTLY IF [NOT] EXISTS so the migration takes no
blocking lock on the high-traffic search_queries table. The migration
runner (Umzug) does not wrap migrations in a transaction, so CONCURRENTLY
is safe here.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wAHcneY9eV4fZtCBq8Ue3
---------
Co-authored-by: Claude <noreply@anthropic.com>
* fix: Vertically center empty state in notifications popover
The empty state relied on percentage heights to center, but the
height chain was broken by the outer container only setting min/max
height. Switch to flexbox growth so the scroll region fills the
available space and the empty message centers reliably.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J7kMKxnH5gfziT5GNgsXZW
* chore: Add development util to create test notifs
---------
Co-authored-by: Claude <noreply@anthropic.com>
* Treat legacy boolean commenting preference as disabled
Teams not yet migrated to the CommentingAccess enum may still have a
boolean `false` stored for the commenting preference. Guard the
enabled checks so `false` reads as disabled rather than enabled.
* Move commenting setting from Details to Security settings
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Bumps dd-trace to ^5.109.0 and @sentry/node + @sentry/react to ^10.58.0,
migrating off APIs removed in the Sentry v8 major: BrowserTracing /
reactRouterV5Instrumentation, Sentry.Handlers.parseRequest, and
Sentry.configureScope.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* feat: Record search query duration in milliseconds
Adds a `duration` column to search_queries that stores how long each
search took, including result presentation time.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
The FileOperation-based ImportTask was superseded by the APIImportTask
pipeline (JSON/Markdown/Notion) in #12361 and #12380. Nothing extends or
imports it any longer.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* fix: Allow webhook urls without a top-level domain when self-hosted
Webhook URL validation required a top-level domain, rejecting valid
internal hostnames such as http://webhook on self-hosted installations.
The TLD requirement is now only enforced when cloud hosted.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor: Extract webhook url validation into reusable IsUrl decorator
Move the conditional top-level domain validation into a reusable IsUrl
validator alongside the other model validators, and restore mocks
between create tests to keep hosting mode isolated.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test: Move webhook url validation tests onto IsUrl validator
The top-level domain validation is owned by the IsUrl decorator, so test
it directly via a collocated unit test rather than through the
webhookSubscriptions API.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* PR feedback
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* fix: Encode code & math fences in table cells with <br> to avoid breaking rows
Code and LaTeX fences inside table cells emitted literal newlines during
Markdown serialization, breaking the single-line table-row structure and
corrupting the whole table. Serialize them on a single line using <br> for
line breaks (and escaped pipes) when inside a table, matching the existing
handling for lists and hard breaks.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: Escape backslashes in table-cell code & math fences
CodeQL flagged incomplete string escaping: escaping pipes as \| without
escaping pre-existing backslashes leaves the encoding ambiguous. Escape the
backslash (the escape character) and pipe together in a single pass so cell
content cannot break out of the column.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test: Cover math block table-cell serialization
Add a test mirroring the code fence case to guard the MathBlock half of the
table-cell <br> encoding and pipe/backslash escaping.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* feat(s3): add optional CloudFront support for signed attachment URLs
Serve attachment downloads through CloudFront when configured, while keeping
uploads on the direct S3 endpoint. Signed URLs require a key pair; missing or
invalid signing config falls back to S3 presigned URLs instead of unsigned CDN
links. CloudFront secrets are kept server-side only.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Update .env.sample
Co-authored-by: Tom Moor <tom.moor@gmail.com>
* Update server/env.ts
Co-authored-by: Tom Moor <tom.moor@gmail.com>
* fix(s3): address CloudFront PR review feedback"
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Tom Moor <tom.moor@gmail.com>
* perf: lazy-load jsdom in DocumentHelper to keep it off startup path
DocumentHelper is imported by the Document and Collection models, so its
eager `import { JSDOM } from "jsdom"` pulled jsdom (~140ms) into every
server process at boot. jsdom is only needed by toEmailDiff for HTML
export, so load it lazily there — matching the existing pattern in the
sibling ProsemirrorHelper.toHTML.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* perf: defer AWS CRT signer load out of the startup path
S3Storage had a top-level `import "@aws-sdk/signature-v4-crt"` side effect
that loaded the native CRT binding (~140ms) whenever the module was
imported — which happens at boot via the Attachment model in every
process, even for local-storage deployments that never construct S3Storage.
Move the import into the S3Storage constructor so the native binding only
loads when S3 storage is actually instantiated, keeping it off the startup
path for local-storage deployments.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* perf: load dd-trace only when APM is enabled
tracer.ts imported dd-trace unconditionally, so the library (which patches
Node internals on require, ~35-80ms) loaded at startup in every process —
including the common self-hosted case where DD_API_KEY is unset and APM
does nothing. tracer.ts is the first import in server/index.ts, so this
cost is fully serial on the boot path.
Require dd-trace only when DD_API_KEY is set; otherwise fall back to a
no-op tracer covering the surface used by callers (scope/startSpan and a
no-op span), so tracing.ts and the named helpers work unchanged. The
dd-trace/ext/tags import used by tracing.ts is a standalone constants
module and does not pull in the full tracer.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
The collaborativeEditing toggle has been unused since collaborative
editing became always-on. The column is no longer defined in the Team
model nor referenced anywhere in the codebase, so this drops it.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* Add restore_document MCP tool and archived/trashed listing
Closes the delete/restore asymmetry in the MCP server: previously documents
could be archived or trashed via delete_document but never recovered.
- Add restore_document tool to recover archived or trashed documents,
optionally into a different collection.
- Add a status option ("archived" | "trashed") to list_documents so agents
can discover what to restore.
- Extract the documents.restore route logic into a shared documentRestorer
command, used by both the REST endpoint and the MCP tool.
https://claude.ai/code/session_01HpFcYtgEZJ96iaFMuGGCmc
* Use type-only import for Document in documentRestorer
https://claude.ai/code/session_01HpFcYtgEZJ96iaFMuGGCmc
* Revert archived/trashed status option on list_documents
Keeps the restore_document tool and shared documentRestorer command;
removes the list_documents status filter and its tests.
https://claude.ai/code/session_01HpFcYtgEZJ96iaFMuGGCmc
---------
Co-authored-by: Claude <noreply@anthropic.com>
* Avoid empty webhook processor work via cached subscription lookup
WebhookProcessor ran for every event but most teams have no matching
webhook subscription, costing an empty processor job and a database query
per event.
Cache a team's enabled subscriptions ({ id, events }) in Redis, invalidated
by model lifecycle hooks, and add an optional BaseProcessor.shouldQueue hook
consulted by the global event queue so the webhook processor only enqueues a
job when a matching subscription exists.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feedback
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* fix: Increase valid user-supplied URL length to 1024
* fix: Wrap URL length migration in a transaction
Wrap the multi-column changeColumn operations in a transaction so a
failure on any column rolls back the whole migration rather than leaving
the database partially migrated.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* fix: Access request logic for collection managers
* test: Exercise collection-manager path in access request regression tests
Grant the non-workspace-admin manager a collection-level Admin membership
instead of a direct document-level membership, so authorization flows
through the collection-manager path being tested for #12567.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* Add tagging of outgoing emails
* Detect SES configured via well-known service key
The isSES check only matched "amazonaws" in the host, so SES configured
through SMTP_SERVICE (e.g. "SES" or "SES-US-EAST-1") was not detected and
tagging headers were not applied.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* perf: Lazy import mailparser, @fast-csv, and franc deps
Moves heavy dependencies off the startup path into the narrow async code
paths that actually use them, mirroring the mammoth lazy-import change:
- mailparser: only needed for Confluence Word imports (confluenceToHtml)
- @fast-csv/parse: only needed for CSV imports (csvToMarkdown)
- franc / iso-639-3: only needed by the DocumentUpdateText worker task
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* perf: Lazy import jsdom dep
jsdom is one of the heaviest server dependencies but is only needed for
HTML export (ProsemirrorHelper.toHTML) and HTML import
(DocumentConverter.htmlToProsemirror). Move it to a lazy `await import`
inside those methods so its dependency tree stays off the startup path.
Both methods become async; all callers were already in async contexts.
The type-only usage in patchGlobalEnv is now an `import type`.
* fix: Run single process when only the worker service is enabled
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* perf: Improve memory consumption through lazy service loading
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
The FileOperation import association was fetched for every non-public
document but only used when sourceMetadata is present. Move the lookup
inside that branch to eliminate an N+1 query for documents that are not
imports, benefiting every endpoint that presents documents.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>