External providers can legitimately report several groups with the same
display name. Previously the second group failed the team-wide name
uniqueness check, or duplicates slipped through on creation and then
broke every subsequent sync with a validation error.
- Scope the group name uniqueness check by (team, externalId) so synced
groups with different external ids can share a name while manually
created groups remain unique among themselves
- Compare names with lower() equality instead of iLike so LIKE wildcards
in names are not treated as collisions
- Stamp externalId on groups created by the syncer and backfill it on
previously synced groups
Nodes are cached against the content or state they were parsed from, so
repeated helper calls on the same document parse it once. JSON transform
helpers now replace attrs instead of mutating them, as Node.toJSON shares
attrs with the cached node.
* perf: Reduce query cost and reparsing in comments API
* perf: Join documents without default associations when listing comments
* refactor: Move comment listing into Comment.findAllForUser
* fix: Revision and document attribution to the wrong user in collaborative edits
Capture the editing user synchronously with each Yjs update and persist an
ordered, sequenced collaborator set in Redis so that snapshots and revisions
are attributed to the user who actually made the change.
* fix: Do not fail a committed save when the update event cannot be scheduled
* fix: Consume collaborator attribution when a revision is skipped as identical
* refactor: Add zlatestWithSequence to the Redis adapter
* feat: Add reasons for archived and deleted documents
* feat: Add deprecation reasons to archived collections
* fix: Refine deprecation reason display for readers
* feat: Accept reasons when archiving or deleting
* Support reasons in archive and delete MCP tools
* Fix placeholder after clearing content editable text
* Keep the caret before content editable placeholders
* Remove test
* feat: Add archive reasons to the confirmation dialog
Adds a server-shared Vitest project with isolate disabled and moves every
server test into it by default. Files that mock or reset modules opt out
with a header marker and stay in the isolated project.
Restores env values that leaked between files: the test URL is reset after
each file, and tests that mutate env restore the previous value. The test
server no longer closes the shared sequelize pool.
* feat: Add Open Knowledge Format (OKF) export
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Separate OKF frontmatter from body, use team URL for resource
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Use OKF initials avatar in export dialog
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Use GlobeIcon for OKF export format
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* React 18 upgrade
* fix: Force synchronous React rendering in server HTML export
React 18 can defer a legacy ReactDOM.render commit when sync work is
queued, leaving exported component nodes empty. Wrap the render in
flushSync, and flush unmount-scheduled passive effects before global
env cleanup so React never runs without a window.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor: Move server ComponentView to createRoot
ReactDOM.render and unmountComponentAtNode are removed in React 19.
flushSync around root.render keeps the mount synchronous for the
HTML-export path, which reads the DOM immediately after.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Enable CI
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* checkpoint
* feat: Convert @ prefixed links to mentions on server Markdown writes
A Markdown link preceded by "@" now becomes a mention when brought in
through the documents API, MCP, or an import, so an exported mention
survives a round trip instead of degrading to a plain link.
The editor rule creates a generic mention carrying the href, and the
type of resource it points at is resolved by the plugin that recognizes
the URL through a new MentionProvider hook. Mentions of external
resources also serialize to their real URL rather than a mention:// URI,
so the reference resolves outside of Outline.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Escape values interpolated into rendered mention HTML
markdown-it leaves markup in a link label intact when html is disabled,
so the label and attributes are escaped before being written into the
tag.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Heading numbers are drawn by a ProseMirror decoration, and the server
strips all plugin decorations before it serializes, so exported HTML
always came out unnumbered.
Compute the same labels during export and write them to the rendered
headings as a data attribute, which the exported editor styles already
render. A revision takes the preference from the document it belongs to.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Make count-based limit checks reliable under concurrency
Limits enforced by counting rows before an insert could be exceeded by
requests that ran at the same time, as each one read the same count
before any of them had written. Add a LockHelper that takes a Postgres
advisory lock for the remainder of the transaction, and use it to
serialize the check for webhook subscriptions, team domains, share
subscriptions and pins. The counts now also run on the transaction so
they include rows written earlier in the same request.
* Remove excessive tests
* Also guard simultaneous row removal
* feat: Record who deleted a document
The trash inferred the deleting user from lastModifiedById, so a nested page
kept whoever last edited it and deleting a document rewrote its edit history.
Add a dedicated deletedById column and set it from the base model.
- Migration adds the column, backfills from lastModifiedById, and validates the
foreign key without holding an exclusive lock. The backfill runs in batches
against a temporary index covering only the rows still to write, so it stays
linear on a large table, and every statement is idempotent because the
migration cannot run in a transaction.
- ParanoidModel records the acting user on destroy and clears it on restore,
for any model that has the column. Sequelize soft deletes with the same UPDATE
that stamps deletedAt, so the value costs no extra query.
- Deleting a document no longer touches lastModifiedById on its descendants.
- Present the deleting user, batched in presentDocuments, and use it for the
trash notice and the document meta line rather than the last editor.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Do not overwrite an eager loaded deleting user when batching
The batch lookup in presentDocuments skipped documents that already carried the
association, but the assignment loop ran for all of them, so a document that
arrived with deletedBy loaded was reset to null and fell back to a per-document
query. Assign only where the association is missing, and deduplicate the ids so
a page deleted by one person asks for one row rather than one per document.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feat: Filter DSL for users.list
Add the structured filter expression language already used by documents.list
and documents.search to users.list, over an allowlist of id, name, email,
role, createdAt, updatedAt, lastActiveAt and suspendedAt.
Supersedes the ad-hoc ids, emails, role and filter parameters, which are now
deprecated and translated into the DSL so a single path builds the query. The
same translation backs the list_users MCP tool, which held a duplicate copy of
the status handling.
Field specs gain an optional value allowlist, so an unknown role is rejected
at the input layer rather than reaching the enum column. Suspended users
remain invisible to non-admins and excluded by default, unless the expression
references suspendedAt.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* refactor: Collapse the duplicate suspended user predicate
The non-admin invariant and the default exclusion pushed the same clause for
non-admins in the default case. Both rules are now one predicate: suspended
users are visible to admins only, and then only on request.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* refactor: Drop the legacy parameters from the list_users MCP tool
The MCP surface has no backwards compatibility burden, so it takes the filter
DSL directly instead of the deprecated role and status parameters. This gives
the model date ranges, OR groups and name matching, which the old enum pair
could not express.
The field allowlist moves next to the other user filter helpers so the REST
schema and the tool share one definition rather than the tools directory
reaching into the routes.
Drops the unreachable Date member of FilterValue. Dates cross the wire as ISO
8601 strings, a Date instance fails every field kind, and zod cannot represent
it in the JSON Schema the MCP tool list is built from.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* revert: Retain legacy role/filter params in the list_users MCP tool for now
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Revert MCP changes
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Add heading numbering display preference for documents
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Fix isRemoteTransaction call for new signature on main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Fix inTable detection for headings after a nested table
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Move from deco to pseudoclass
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
jsdom does not implement ResizeObserver, so a PDF attachment preview in a
publicly shared document threw from a React passive effect during HTML
rendering. Effect errors are not caught by the node view fallback, so the
uncaught exception took down the process.
Fixes OUTLINE-CLOUD-D14
Viewing the trash showed everything the whole workspace had deleted, which
is noisy for anyone looking for their own document. Default the view to the
items the current user deleted, and add user and date filters — matching the
shape of the search filters — to widen it again.
- Attribute a deleted subtree to the acting user. Deleting a document only
recorded the actor against the document itself, so nested pages kept
whoever last edited them and would have been hidden from their deleter.
- Move documents.deleted onto the filter DSL, exposing deletedById and
deletedAt. deletedById is mapped to the column that currently records the
deleting user, so adding a dedicated column later leaves the API unchanged.
- Lift the date filter duration map into shared, where search and the trash
both read it rather than keeping a copy each.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Render React node views in server-side HTML export
Passes nodeViews to the headless EditorView used for export so that nodes
with a React component render with it, matching the editor, and falling
back to toDOM when a component cannot render server-side.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Let nodes opt out of component rendering in static HTML
Replaces the hardcoded set of node names in the server nodeViews factory with
an allowComponentInStaticHTML getter on Extension, so a node declares the
behavior alongside its own definition rather than in a server file that does
not know about it.
Mention opts out: its component requires stores and a router, so it always
threw and fell back to toDOM, at the cost of a React render, an exception and
a log line per node. A document with 100 mentions now exports in ~12ms rather
than ~25ms and emits no warnings.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Yield one less macrotask turn when flushing React effects
Only two turns are needed: the first flushes passive effects, the second fires
Frame's own setTimeout(0) whose setState commits the iframe. The third turn
absorbed nothing that the components produce.
Each turn is roughly a millisecond of idle time held inside the render lock, on
every export — including plain documents, share page SSR and notification
emails — so dropping it takes a small export from ~6ms to ~4ms.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* fix: Serialize external mentions as links in exported markdown
GitHub issue, pull request and project mentions carry the real URL in
`href`, but always serialized to a mention:// reference that cannot be
resolved outside of Outline. Write a plain link instead when the
commonMark serializer option is set, and set that option on the paths
where markdown leaves the platform – document and revision export, zip
exports, and the public share markdown response.
* Sanitize external mention url before navigation
* feat: Normalized filter DSL for documents.list and search
Add a structured filter expression language (field/operator/value leaves
composed with AND/OR groups) shared by documents.list, documents.search and
documents.searchTitles. Values are validated against each field's column type
and per-field operator allowlists at the input layer, and translated to
Sequelize where-clauses server-side.
Supersedes the ad-hoc statusFilter/dateFilter/collectionId/userId parameters,
adds ISO 8601 duration matching for date fields, documentId subtree expansion
for search, and preserves draft visibility and collection authorization.
* chore: Fix flaky Encrypted "different key" test
AES-256-CBC is unauthenticated, so decrypting with the wrong key only
raises "bad decrypt" when the garbage plaintext has invalid PKCS#7 padding
(~255/256 of the time). Roughly 1 in 245 runs it decrypts to a non-matching
value instead of throwing, failing the strict toThrow assertion. Accept
either outcome, mirroring the adjacent tampered-data test.
* Hardening
The wrong-key test asserted a throw, but AES-256-CBC is unauthenticated so
decryption only fails when the resulting plaintext has invalid padding —
around 0.4% of runs returned garbage instead. Accept either outcome, matching
the pattern already used by the sibling tamper test.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Suggested users that share a group with the mentioning user are ranked
above the rest, both in the query so they fit inside the limit, and in
the menu itself.
The server returns a familiarity score per model id, which the client
applies as a multiplier on the relevance score of a suggestion. This
leaves room for other signals, and for other model types, without a
change to the response shape.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Skip revision diff when too expensive to compute
Recreating steps from a JSON patch copies and validates the full document
once per operation, so a structure collapse on a very large document could
block the worker event loop for minutes. Skip the changeset when the
product of operation count and document size exceeds a bound, and send
notification emails without the inline preview in that case.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* perf: Apply complexity guard to every patch computation
Centralize patch creation and the maxComplexity check in recalculateOps
so the recomputed patch in addSetNodeMarkup is bounded as well.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* fix: Consume OAuth authorization codes and refresh tokens atomically
The exchange of an authorization code, and the rotation of a refresh
token, read the credential and deleted it in two steps. Concurrent
requests with the same credential could both pass the read and each
receive a token.
Claim the credential with a single conditional statement instead, so
that only one of a set of concurrent requests continues to token
issuance.
* fix: Move OAuthAuthentications delete to predicate-scoped destroy.
* fix: Apply all content transforms in DocumentHelper.toJSON
replaceInternalUrls was declared async although it does no async work, so the
promise it returned was passed into removeMarks, which returned it untouched
rather than walking it. Made the method synchronous, and typed the local in
toJSON so the compiler reports a promise flowing through the transform chain.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* chore: JSDoc punctuation and explicit return type on replaceInternalUrls
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Warn before discarding unsaved template changes
Template content is only persisted when the form is explicitly submitted,
so navigating away or closing the tab silently lost everything typed.
Adds a navigation Prompt and a beforeunload handler to both template
scenes, and reverts the model on unmount so abandoned edits no longer
leak into other views rendering the same record.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Persist templates from the first keystroke
New templates were held only in browser memory until Save was pressed, so
a refresh, crash, or stray navigation lost everything written.
Templates are now created up front as an unpublished draft and autosaved,
mirroring how documents behave. Drafts are visible only to their author
until published, and are cleaned up if abandoned while empty.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Preserve icon edits made during an in-flight template save
applyEdits only restored title and content, so an icon or color changed
while a save was in flight was overwritten by the response and never
re-saved.
Pending edits are now tracked as a single record covering every field the
form can change, rather than one ref per field.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feedback
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* perf: Reduce database and Redis round-trips on the MCP endpoint
Profiling production traces for the /mcp endpoint showed the time is
spent in repeated permission and breadcrumb lookups rather than in the
MCP layer itself.
- Cache Document.membershipDocumentIds in Redis, mirroring the TTL and
key pattern of User.collectionIds. The two are resolved together for
every search and this half was uncached, measuring ~200ms.
- Resolve each collection's cached document structure once, concurrently,
when building breadcrumbs for a batch of documents. It was awaited per
document inside a loop, so a page of search results meant a serial
Redis round-trip for every result.
- Walk each collection structure once into a document ID to breadcrumb
map instead of searching the whole tree per document.
- Reuse the collection association already loaded by Document.findByPk
when resolving a single document's breadcrumb, rather than querying it
again under the same membership scope.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Invalidate cached document membership IDs on permission changes
The cache added alongside membershipDocumentIds relied on its TTL alone,
so a revoked grant stayed searchable until it expired. Clear the key on
the paths that change which documents a user is a member of, keeping the
TTL as a backstop.
- UserMembership create and destroy where documentId is set.
- GroupMembership create and destroy where documentId is set, for every
user in the group.
- GroupUser create and destroy, as joining or leaving a group changes
which group grants reach the user.
Sourced memberships are written with hooks disabled and destroyed without
individual hooks, so the parent membership invalidates once for the group
rather than once per descendant.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Sanitize user-provided name when building export storage keys
Export keys interpolated a document title or collection name straight
into the storage path, so a name containing path separators could move
the archive out of the uploads bucket and into public, where files.get
serves content without authorization.
Sanitize the name down to a single path segment, dedupe the duplicated
key builder in collectionExporter, and reject traversal in LocalStorage
where resolve-path only guards the root, not movement between buckets.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* chore: Complete JSDoc on export key helpers
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Deleting a document walked its subtree with one query per document and
destroyed each in a serial post-order recursion, so large subtrees could
exceed the request statement_timeout.
Resolve the subtree with the existing recursive CTE helper and load the
children in a single query instead. Documents are still destroyed one at
a time so model hooks run for each, and deepest-first ordering is kept.
The subtree lookup also dropped the options it was passed, so it ran
outside the request transaction.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
FOR UPDATE conflicts with the FOR KEY SHARE lock Postgres takes on a
parent row when checking a foreign key, so every insert referencing a
collection blocked behind unrelated document structure updates in it.
FOR NO KEY UPDATE still self-conflicts, keeping structure writers
mutually excluded, without blocking child row inserts.
Adds a sourceMetadata JSON column to revisions, populated with the
authentication type of the request that produced the edit, so the
document history sidebar can show "Tom edited via MCP"
* fix: Allow inline comments on documents without collaborative state
Documents created through the API have no collaborative state until they
are opened in an editor, which made anchored comments fail. Derive the
state from the document content when it is missing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test: Read comment marks from content instead of decoding state
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test: Read node-anchored comment mark from content
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Remap internal links when duplicating a document tree
Duplicating a document tree now assigns the identifiers of every duplicate
before any content is written, so links and mentions between the documents
being duplicated point at the copies rather than the originals.
* fix: Remap fully qualified links when duplicating a document tree
Links written as a full url to this installation are now remapped alongside
relative ones, and stay fully qualified. Where a link is displayed as its own
url the text is updated to match.
Also trims surrounding whitespace in sanitizeUrl, which otherwise failed
validation and prepended a second scheme to an already qualified url.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Remap links across trees when duplicating a collection
The collection duplication task duplicated each root document separately, so
only links within a single tree were remapped. It now duplicates the whole
collection as one unit, with identifiers assigned across every tree before any
content is written.
* fix: Match document links by identifier rather than host when duplicating
An installation can be reached through more than one host, so comparing a
link's host against the configured url left fully qualified links to a
document in the duplicated set unmapped. The document a link identifies now
decides whether it is replaced, and the host it was written with is kept.
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feat: Add TextPack (.textpack) import support
Adds a single-document importer for TextPack, the zipped variant of
TextBundle used by Bear, Ulysses, iA Writer and others. Bare .textbundle
directories are not supported, as a directory cannot be delivered through
a browser file input.
The bundle's text entry may use any extension, per the spec, with
info.json's type deciding whether it can be read as markdown. Assets are
inlined as data URIs for the existing attachment pipeline to pick up,
bounded by the attachment size limit and a memory ceiling, and only for
media types markdown-it accepts as a link destination.
Also fixes an existing bug where a file embedded in an HTML or email
import as a data URI was stored in the document as base64 rather than
being uploaded as an attachment.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Refactor to individual converters
* refactor
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>