Commit Graph
1036 Commits
Author SHA1 Message Date
Tom Moor 42f29a1a55 feat: Add plan-based feature entitlements (#13896)
* feat: Add plan-based feature entitlements

* feat: Gate audit log behind AuditLog entitlement

* Guard guests

* features
2026-09-27 09:40:50 -04:00
Tom Moor aacc98475d fix: Sync external groups with duplicate names accurately (#13894)
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
2026-09-26 08:07:19 -04:00
Tom Moor d5bc88f893 perf: Memoize Prosemirror parsing in DocumentHelper (#13892)
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.
2026-09-25 20:57:58 -04:00
Tom Moor b6231f36c9 perf: Reduce query cost and reparsing in comments API (#13887)
* 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
2026-09-25 20:08:59 -04:00
Tom Moor ed4aaf274d fix: Update group timestamp when membership changes (#13888) 2026-09-25 17:17:05 -04:00
Tom Moor 018d386030 perf: Remove redundant queries from document API routes (#13884) 2026-09-25 07:16:04 -04:00
Tom Moor fcb5f7934d fix: Keep attachments private when S3 ACLs are disabled (#13867) 2026-09-23 18:56:59 -04:00
Tom Moor de33f87aea refactor: move revision and export logic out of commands (#13856) 2026-09-23 08:10:03 -04:00
Tom Moor 70ea374543 fix: Language detection stores nothing for Chinese, Arabic, Persian and other macrolanguages (#13833) 2026-09-21 20:35:45 -04:00
Tom Moor 18a7099e8f fix: Document search trigger fails when tsvector exceeds size limit (#13832)
* fix: Document search trigger fails when tsvector exceeds size limit

* test: Assert previous titles are indexed in the tsvector fallback
2026-09-21 20:31:34 -04:00
Tom Moor 5693562624 fix: Revisions sometimes attributed to the wrong user in collaborative edits (#13809)
* 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
2026-09-20 14:05:50 -04:00
Tom Moor a7c1907aa6 Strip top-level domain from generated team subdomain (#13816)
* fix: Strip top-level domain from generated team subdomain

* Move subdomain generation into Team.findAvailableSubdomain and reuse in installation
2026-09-20 13:31:39 -04:00
Tom Moor c17d2c52b3 fix: Patch edit mode drops content spliced inside container blocks (#13794)
* fix: Patch edit mode drops content spliced inside container blocks

* fix: Only join adjacent lists that share attrs other than start number
2026-09-19 09:16:52 -04:00
Tom Moor 7f00defd62 feat: Add archive and deletion reasons (#13784)
* 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
2026-09-18 21:09:35 -04:00
Tom Moor 6ac407de84 chore: Run server tests with a shared module registry (#13799)
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.
2026-09-18 17:45:39 -04:00
Tom Moor b21174ccbf perf: Avoid N+1 query in share subscription notifications (#13719) 2026-09-10 10:11:11 -04:00
Tom MoorandClaude Fable 5.1 a577d5c2c8 fix: Validate API key and OAuth scopes at the model layer (#13664)
* fix: Validate API key scopes with Sequelize-level validators

* test: Add API regression tests for duplicate OAuth redirect URIs

* fix: Preserve wildcard scope and guard non-string redirect URIs

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-04 23:10:32 -04:00
Tom MoorandClaude Fable 5.1 899fb8a22e feat: Add Open Knowledge Format (OKF) export (#13644)
* 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>
2026-09-04 08:15:07 -04:00
Tom MoorandClaude Fable 5 b17f2611bf chore: React 18 upgrade (#13559)
* 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>
2026-09-03 01:43:47 -04:00
dependabot[bot]andTom Moor 182c60c696 chore(deps-dev): bump @faker-js/faker from 8.4.1 to 10.5.0 (#13618)
* chore(deps-dev): bump @faker-js/faker from 8.4.1 to 10.5.0

Bumps [@faker-js/faker](https://github.com/faker-js/faker) from 8.4.1 to 10.5.0.
- [Release notes](https://github.com/faker-js/faker/releases)
- [Changelog](https://github.com/faker-js/faker/blob/next/CHANGELOG.md)
- [Commits](https://github.com/faker-js/faker/compare/v8.4.1...v10.5.0)

---
updated-dependencies:
- dependency-name: "@faker-js/faker"
  dependency-version: 10.5.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

* faker.name -> faker.person

* chore: update vulnerable transitive dependencies

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tom Moor <tom@getoutline.com>
2026-09-02 23:20:23 +00:00
Tom MoorandClaude Opus 5 f49b047648 feat: Convert @ prefixed Markdown links to mentions on server writes (#13403)
* 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>
2026-08-27 17:42:28 -04:00
Tom MoorandClaude Opus 5 d2697d354e fix: Respect heading number preference in HTML export (#13563)
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>
2026-08-27 15:27:02 -04:00
Tom Moor aab83e8378 fix: Reliability of count-based limit checks (#13542)
* 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
2026-08-24 19:14:55 -04:00
Tom MoorandClaude Opus 5 def3a42752 feat: Record who deleted a document (#13484)
* 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>
2026-08-22 21:49:31 -04:00
Tom MoorandClaude Opus 5 41616f73cc feat: Filter DSL for users.list (#13456)
* 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>
2026-08-22 10:47:32 -04:00
Tom MoorandClaude Fable 5 662bad7108 Add heading numbering display preference for documents (#13522)
* 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>
2026-08-22 09:44:42 -04:00
Tom Moor 87da583bc1 fix: Provide a ResizeObserver stub when rendering documents server-side (#13478)
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
2026-08-18 19:11:42 -04:00
Tom MoorandClaude Opus 5 e4905a97b8 feat: Filter the trash by who deleted an item and when (#13474)
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>
2026-08-18 08:33:58 -04:00
Tom MoorandClaude Opus 5 eaad1a71dc React SSR editor nodes (#13113)
* 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>
2026-08-16 16:36:13 -04:00
Tom Moor a59a01cffe fix: Serialize external mentions as links in exported markdown (#13459)
* 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
2026-08-16 14:14:20 -04:00
Tom Moor fc4fe65155 feat: Filter DSL (#12176)
* 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
2026-08-15 13:25:10 -04:00
Tom MoorandClaude Opus 5 1309dc26eb chore: Fix flaky Encrypted decorator test (#13436)
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>
2026-08-15 03:09:17 +00:00
Tom MoorandClaude Opus 5 9cc3542dba feat: Rank mention suggestions by familiarity (#13435)
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>
2026-08-14 21:21:34 -04:00
Tom MoorandClaude Fable 5 7764c95e80 perf: Skip revision diff when too expensive to compute (#13432)
* 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>
2026-08-14 17:56:16 -04:00
Tom Moor 187a5f8926 fix: Tighten one-time credential handling in OAuth token exchange (#13417)
* 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.
2026-08-13 22:32:22 -04:00
Tom MoorandClaude Opus 5 96cf0a4034 fix: Apply all content transforms in DocumentHelper.toJSON (#13413)
* 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>
2026-08-13 21:01:10 +00:00
Tom Moor ef0240c41c fix: Improve matching of anchorText property (#13385)
* fix: Improve matching of anchorText property

* feedback
2026-08-12 08:24:41 -04:00
Tom Moor a0fcc32622 Normalize document export options (#13364) 2026-08-10 07:43:37 -04:00
Tom MoorandClaude Opus 5 e4d07b4f24 Persist template drafts as they are written (#13357)
* 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>
2026-08-09 00:09:20 +00:00
Tom MoorandClaude Opus 5 399cd4041d perf: Reduce database and Redis round-trips on the MCP endpoint (#13333)
* 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>
2026-08-07 19:01:02 -04:00
Tom MoorandClaude Opus 5 df64de9b3c fix: Back off repeated confirmation emails for share subscriptions (#13342)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-07 18:04:40 -04:00
Tom MoorandClaude Opus 5 fc7f33577f fix: Sanitize user-provided name when building export storage keys (#13336)
* 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>
2026-08-07 21:58:58 +00:00
Tom MoorandClaude Opus 5 2bf160ec39 perf: Avoid N+1 queries when deleting a document subtree (#13311)
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>
2026-08-05 20:44:29 -04:00
Tom Moor 9c3bff9b7a perf: Use FOR NO KEY UPDATE for collection structure locks (#13314)
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.
2026-08-05 20:30:34 -04:00
Tom Moor 81d9bed9ba feat: Attribute revisions to the auth type they were made with (#13312)
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"
2026-08-05 20:07:03 -04:00
Tom MoorandClaude Opus 5 e737968365 fix: Allow inline comments on documents created via the API (#13289)
* 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>
2026-08-03 18:26:01 -04:00
Tom MoorandClaude Opus 5 b2b41dd3ca fix: Remap internal links when duplicating a document tree (#13270)
* 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>
2026-08-02 22:44:06 -04:00
Tom MoorandClaude Opus 5 000f2f98fb feat: Add TextPack (.textpack) support (#13235)
* 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>
2026-08-02 20:42:05 -04:00
Tom Moor 33c8d51e08 perf: Avoid membership joins in search (#13269)
* perf: Avoid membership joins in search

* feedback
2026-08-02 18:29:16 -04:00
Tom Moor b1b3db3430 Update all MCP tools to Markdown (#13234)
* Update all MCP tools to MD input+output

* feedback
2026-08-02 07:58:15 -04:00