Commit Graph
3138 Commits
Author SHA1 Message Date
Claude 2c354673ee perf: reduce per-item queries on hot paths and add missing indexes
- presentDocuments: batch-load collection deletedAt for archived/deleted
  documents so trash and archive listings no longer issue one Collection
  query per document via isCollectionDeleted
- documents.search: present results through the batched presentDocuments
  helper instead of one presentDocument call per result
- revisions.list: load collaborators for the whole page in a single User
  query instead of one per revision, and stop fetching the unused content
  and text columns when listing without content
- TextHelper.attachmentsToSignedUrls: fetch all attachments in one query
  instead of one findOne per attachment id
- BacklinksProcessor: resolve linked documents and existing backlinks in
  bulk queries and create missing backlinks with a single bulkCreate
- NotificationHelper: batch the per-recipient View lookup when filtering
  comment notification recipients
- Add indexes covering hot queries that previously scanned: events
  (teamId, createdAt) for the audit log, and shares (documentId) /
  (collectionId) for shareLoader lookups

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTaaEHNxBrmBnoVa5iSJV6
2026-07-05 09:51:14 +00:00
Tom Moor 3e5d21fa11 fix: revisions.list response too large (#12822) 2026-06-30 13:35:30 -04:00
Tom Moor ec3200c7d2 chore: babel -> swc (#12821)
* chore: babel -> swc

* Add ls guard

* PR feedback
2026-06-29 17:11:02 -04:00
Tom MoorandClaude Opus 4.8 695042b2af feat: Batch RPC endpoint (#12820)
* batch RPC endpoint

* Clamp batch socket timeout between 15s and 25s

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 02:39:30 -04:00
Cassiano Vailati 34907e1500 fix: Add WWW-Authenticate header to /mcp 401 responses (#12834)
* fix: Add WWW-Authenticate header to /mcp 401 responses

RFC 9728 and the MCP authorization spec require protected resources to
include a WWW-Authenticate header on 401 responses so clients can
discover the authorization server via the resource metadata document.

* fix: Preserve existing WWW-Authenticate and guard against non-object errors

Avoid overwriting an upstream WWW-Authenticate header if one is already
present on the error (case-insensitive lookup), and only attempt to
attach headers when the thrown value is a non-null object.
2026-06-25 21:21:15 -04:00
Cassiano Vailati 4845da08ac fix: Make client_name optional on /oauth/register (#12836)
RFC 7591 §2 marks every client metadata field as OPTIONAL. Outline's
schema currently treats client_name as required, which rejects MCP
clients that omit it during dynamic registration. The field becomes
optional and a generic 'Untitled application' label is used when the
caller doesn't supply one.
2026-06-25 20:49:41 -04:00
Tom MoorandClaude Opus 4.8 7b809ab48c fix: Avoid SequelizeEmptyResultError when team is missing in CollectionsProcessor (#12837)
Drop rejectOnEmpty so a deleted team yields null and the existing optional
chaining guard short-circuits the no-op transaction.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 20:49:09 -04:00
Tom MoorandClaude Opus 4.8 6a81426181 fix: Avoid SequelizeEmptyResultError in AvatarProcessor (#12838)
The team or user can be deleted before the async processor runs, so
gracefully skip the avatar upload instead of throwing.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 20:49:05 -04:00
Tom MoorandClaude Opus 4.8 e237e6df47 fix: Handle deleted user or team in UserCreatedProcessor (#12839)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 20:49:02 -04:00
Yinhao HuangandClaude Opus 4.8 6286d08171 feat: support presigned PUT uploads for S3-compatible storage (#12748)
* feat: support presigned PUT uploads for S3-compatible storage

Add `AWS_S3_UPLOAD_METHOD` config ("post" default / "put") so providers
that do not implement presigned POST (e.g. Cloudflare R2) can use
presigned PUT instead.

- BaseStorage.getPresignedPut() returns undefined by default; S3Storage
  overrides with PutObjectCommand + getSignedUrl.
- Content-Length is signed into the presigned PUT URL so S3 rejects
  uploads that do not match the declared size.
- API route and MCP tool branch on the config: only one upload method
  is returned per request.
- Frontend uses existing presignedPutUrl presence check — unchanged.
- When put is configured but unsupported (e.g. LocalStorage), a clear
  InvalidRequestError is returned.

Defaults to "post" — zero behavior change for existing deployments.

* refactor: return explicit upload mode instead of inferring from fields

Address review feedback from @tommoor: the client should not need to
infer the upload method from the presence of presigned-PUT-specific
fields. The API now returns an explicit `mode` ("put" | "post"), and the
PUT branch uses generic `url` / `headers` fields so the client has no
special knowledge of "presigned puts".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* refactor: use this.getBucket() in presigned post/put methods

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 21:05:16 -04:00
Tom Moor c3669a1f1a fix: Guard against orphaned jobs in queue (#12819) 2026-06-24 17:54:08 -04:00
Tom Moor 5f236935bc fix: CleanupDemotedUserTask throws on deleted user (#12818)
closes #12815
2026-06-24 17:54:01 -04:00
Tom Moor 97c6cc3ab3 fix: Guard missing key in manifest (#12806) 2026-06-23 21:16:20 -04:00
Tom MoorandClaude Opus 4.8 e646b14225 fix(test): restore plugin loading under Vite 8 (#12792)
* fix(test): restore plugin loading under Vite 8

Vite 8 dropped support for extglob negation (`!(...)`) in glob patterns,
so the test setup's plugin glob matched zero files and no plugin routes
were registered, causing every plugin API test to 404. Use Vite's
array-with-negative-patterns syntax to exclude test and schema files.


---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 21:41:47 -04:00
Tom MoorandClaude Opus 4.8 19a4922ed1 fix: Ensure mention in doc emails always include context (#12787)
* 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>
2026-06-22 19:28:26 -04:00
Tom MoorandClaude Opus 4.8 7cff0911cd fix: Notion import crash on empty table ("Index 0 out of range") (#12775)
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>
2026-06-22 18:34:23 -04:00
Tom Moor bd013dbfa5 fix: Remove quote flattening on markdown serialization (#12774)
* fix: Remove quote flattening on markdown serialization

closes #12773

* PR feedback
2026-06-21 18:36:00 -04:00
Tom Moor e1a6c986b7 Remove settings from integration presenter (#12770)
* Remove settings from integration presenter

* refactor
2026-06-21 15:06:10 -04:00
Tom MoorandClaude Opus 4.8 b2bf82d78b Add composite (userId, createdAt) index for searches.list (#12767)
* 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>
2026-06-21 08:01:56 -04:00
Tom Moor 1265d23482 fix: Viewer can disclose existing shared document (#12769) 2026-06-21 08:00:16 -04:00
Tom MoorandClaude Opus 4.8 8cd23e40bf fix: Vertically center empty state in notifications popover (#12764)
* 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>
2026-06-20 21:42:18 -04:00
Tom MoorandClaude Opus 4.8 4383324b30 feat: Add setting to enable guest commenting (#12591)
* 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>
2026-06-20 11:26:05 -04:00
Tom MoorandClaude Opus 4.8 cd4b324f5a chore: Upgrade dd-trace and Sentry (node/react) to v10 (#12759)
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>
2026-06-19 20:50:45 -04:00
Tom Moor 3b4f2ddac0 chore: Vendorize sequelize-encrypted (#12757) 2026-06-19 17:24:42 -04:00
Tom MoorandClaude Opus 4.8 f5f81f8d3a feat: Record search query duration in milliseconds (#12755)
* 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>
2026-06-19 16:39:50 -04:00
Tom Moor 4c36bd83de fix: Prevent concurrent OAuth refresh attempts from revoking grant (#12752)
* Prevent concurrent refresh attempts from revoking grant

* test
2026-06-19 15:58:51 -04:00
Tom MoorandClaude Opus 4.8 f7f0e9fdfe chore: Remove dead ImportTask base class (#12741)
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>
2026-06-18 18:47:25 -04:00
Tom Moor 0ba430e111 fix: Newlines in block fences in table cells (#12740)
* fix: Newlines in block fences in table cells

closes #12736

* refactor
2026-06-18 18:21:50 -04:00
Tom Moor 66eee9007f chore: Upgrade to Typescript 6 (#12737)
* chore: Upgrade TypeScript to 6.0
2026-06-18 17:34:05 -04:00
Tom Moor 06c5188184 fix: Importer fails after stripping emoji within mark on first line (#12730) 2026-06-17 22:53:50 -04:00
Tom Moor 7ad35252fd fix(mcp): Documents shared directly with user not accessible through list tool (#12717)
* fix: Documents shared directly with user not accessible through list tool

closes #12716

* fix
2026-06-17 20:29:17 -04:00
Tom MoorandClaude Opus 4.8 8183c8e032 fix: Allow webhook urls without a top-level domain when self-hosted (#12728)
* 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>
2026-06-17 20:29:03 -04:00
Tom Moor 6ed1e71157 fix: Pinterest host matching too broad (#12718) 2026-06-16 22:29:17 -04:00
Tom Moor ef5e1c10b4 fix: Template management can never be extended to viewers (#12719)
closes #11807
2026-06-16 22:29:09 -04:00
Ori dc38abc475 only users with "manage" permissions can edit page permissions (#12597)
* only users with "manage" permissions can edit page permissions

* Fix document permission test authentication

* allow manage perms on archived docs
2026-06-15 18:48:12 -04:00
Tom MoorandClaude Opus 4.8 c59e8bcc3f fix: Encode code & math fences in table cells with <br> to avoid breaking rows (#12569)
* 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>
2026-06-14 23:03:14 -04:00
2a5346d326 feat(s3): add optional CloudFront support for signed attachment URLs (#12656)
* 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>
2026-06-14 10:14:01 -04:00
Tom MoorandClaude Opus 4.8 3e4727d67c perf: Server startup time (#12680)
* 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>
2026-06-13 13:50:51 -04:00
Tom Moor 394c6e3b03 fix: Duplicate paths in export ZIP (#12674) 2026-06-12 20:04:18 -04:00
Tom MoorandClaude Opus 4.8 9113501906 Add PROXY_HEADERS_TRUSTED env (#12676)
* Add PROXY_HEADERS_TRUSTED env

* Don't trust X-Forwarded-Proto for HTTPS redirect when proxy headers untrusted

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 19:58:16 -04:00
Tom MoorandClaude Opus 4.8 b1bf7c488b chore: Drop dead collaborativeEditing column from teams (#12669)
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>
2026-06-11 22:16:08 -04:00
Tom Moor c65b020655 fix: Reject collections.update requests that include both description and data (#12648) 2026-06-11 21:30:47 -04:00
Tom Moor 3c2e9a9723 fix: Default collections created through MCP to private (#12644) 2026-06-09 08:38:34 -04:00
Tom Moor bd01a62fc1 feat: MCP template support (#12639) 2026-06-09 07:43:21 -04:00
Tom Moor a2f9962958 fix: Update validateUrlNotPrivate to match implementation in SSRF (#12636) 2026-06-08 19:35:46 -04:00
Tom Moor 053693b9d5 fix: Spurious post-import edits (#12620) 2026-06-07 21:13:23 -04:00
Tom Moor 9b8acf3efb Remove unnecessary default parameter values from function signatures (#12617)
* Fix remaining no-useless-default-assignment lint warnings

* Promote no-useless-default-assignment lint rule to error
2026-06-07 15:46:01 -04:00
Tom Moor 0d198294eb fix: Improve patch merging of links in table cells (#12614)
* fix: Improve merging of links in table cells through patch

* PR feedback
2026-06-07 12:09:44 -04:00
Tom MoorandClaude 492af6683b Add document restore functionality to MCP tools (#12575)
* 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>
2026-06-06 15:08:52 -04:00
Tom Moor b23a39bd39 Add email verification check during sign-in flow (#12605)
* Add email verification check during sign-in flow

* Add support for Entra External ID with OIDC standard verification claim
2026-06-06 08:01:26 -04:00