Moves lazyWithRetry to shared/utils so the editor's ColorSwatch and
Mentions components can use it instead of React.lazy, avoiding the
Suspense reveal throttle once the chunk is loaded.
Lazy components now render synchronously once their chunk is loaded and share a
preload promise, so the editor no longer commits a fallback and waits out the
300ms retry throttle. Editor chunks are preloaded from the document route, the
sidebar hover, and the data loader. A lint rule blocks direct imports of the
editor chunk.
* fix: Warn before leaving a document with unsynced edits
* refactor: Move unsynced change tracking into CollaborationProvider
* refactor: Move collaboration event types next to CollaborationProvider
* fix: Pending changes stuck after the collaboration connection is restored
* chore: Log collaboration sync state changes in development
* fix: Report lost local persistence in the leave prompt
* fix: Stop local persistence when the initial read fails
* fix: Stop local persistence when a write aborts
* Remove test
* Show toast with actions when a file download completes
In the desktop app a toast is now displayed when a file finishes
downloading, with the option to open the file or reveal it in the file
manager of the operating system.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kat47mueTm3CUZSbDVfBas
* Guard download bridge calls for older desktop apps
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kat47mueTm3CUZSbDVfBas
* Change protocol in dev for easier testing
* Use standard buttons stacked below the file name in download toast
---------
Co-authored-by: Claude <noreply@anthropic.com>
* feat: Support HEIC avatar uploads with in-browser conversion
HEIC and HEIF images picked for an avatar are now converted to JPEG in
the browser before the cropper opens. The browser's own decoder is used
when it supports the format, otherwise a WebAssembly decoder is loaded
on demand.
Also collects the image utilities into an ImageHelper class, fixes the
crop dialog's submit button never disabling, and stops the upload from
forwarding request headers the browser controls itself.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* refactor: Use only the browser's own HEIC decoder
Drops the bundled WebAssembly decoder in favour of the browser's native
support. This removes an LGPL dependency and a 3MB lazy chunk, and lets
the Content Security Policy stay as it was.
Browsers without HEIC support now get a message asking for a JPEG or PNG.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* docs: Add class-level JSDoc to ImageHelper
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* chore: Vendorize y-indexeddb persistence
Replaces the y-indexeddb dependency with a small typed module in
app/utils/IndexeddbPersistence.ts so we have full control over the
underlying database rows. The IndexedDB schema is unchanged and remains
compatible with databases created by y-indexeddb, so existing local
caches continue to work.
Differences from upstream:
- Promise-based API (whenSynced) instead of the lib0 Observable events,
which simplifies MultiplayerEditor and lets it handle environments
where IndexedDB exists but cannot be opened (e.g. Firefox private
browsing) by falling back to no local persistence.
- Skips writing an empty state row every time a document is opened.
- Exposes a public compact() to merge all rows into one on demand.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYncL4PQ5jaEeMBNgjRzf9
* chore: Remove persistence tests and fake-indexeddb dependency
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYncL4PQ5jaEeMBNgjRzf9
* chore: Make trim size a private class member, drop unused custom store
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYncL4PQ5jaEeMBNgjRzf9
* fix: Guard async persistence callbacks against post-cleanup state updates
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYncL4PQ5jaEeMBNgjRzf9
* Added onversionchange handler
---------
Co-authored-by: Claude <noreply@anthropic.com>
* fix: Recover from closed IndexedDB connections in store persistence
StorePersistence cached a single IDBDatabase forever, so once the browser
or another tab closed the connection every subsequent hydrate, flush and
clear threw against a dead handle.
- Close and forget the connection on versionchange, so another tab is
never blocked from deleting or upgrading the database
- Discard the cached connection on close, open error and blocked, and
retry once against a fresh connection when one was closed underneath us
- Close open connections before deleteAllDatabases removes them, which
also stops logout recreating the databases it just deleted
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Cancel pending writes when store persistence is disabled
A debounced flush scheduled before disabling would still fire, reopening
and recreating the database that deleteAllDatabases had just removed.
A dynamic import can resolve to a chunk from a different build, throwing
"does not provide an export named", which was not recognized as a chunk
error. Share one stale chunk matcher between the lazy import retry, the
error boundary, and Sentry so all three treat it as recoverable.
Fixes OUTLINE-CLOUD-D1M
* feat: Persist policies to IndexedDB so abilities survive reload
Adds a StorePersistence layer that caches a store's models in IndexedDB
and hydrates them back at boot as stale data, revalidated by normal API
traffic. Enabled for the policies store, scoped per team, so cached
abilities are available immediately after a reload instead of every
policy needing a forced refetch.
- Persistence hooks in the base Store add/remove/clear methods, since
add() updates existing models in place and map observation would miss
those changes
- Enabled from RootStore construction (team read from localStorage) and
again after auth.info succeeds to cover the first session after login
- Store.clear() wipes the persisted records, covering both logout paths
- deleteAllDatabases() fallback removes the policies database on
browsers without indexedDB.databases()
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XisV6sRdexfnPSiehurKoV
* refactor: Opt stores into persistence via a persistable property
Stores now declare persistence with `persistable = true` and RootStore
sweeps all persistable stores, deriving each database name from the
store's apiEndpoint, instead of RootStore hard-coding the policies
store. The deleteAllDatabases fallback uses the same sweep.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XisV6sRdexfnPSiehurKoV
* refactor: Simplify store persistence enablement and clearing
- Move the persistable guard into Store.enablePersistence so RootStore
can call it unconditionally on every store
- StorePersistence derives its own database name from the store and
teamId rather than receiving a prebuilt name
- StorePersistence.clear returns a promise, making the test deterministic
instead of sleeping
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XisV6sRdexfnPSiehurKoV
* fix: Avoid re-persisting hydrated records, await clear transaction
Hydration called store.add() for every cached record, which now triggers
persist() and scheduled a flush that wrote the just-loaded data straight
back to IndexedDB at boot. Guard persist() with a hydrating flag.
clear() awaited the objectStore.clear() request rather than the enclosing
transaction, so it could resolve before commit and miss abort errors.
* lock
* iterate
---------
Co-authored-by: Claude <noreply@anthropic.com>
* fix: Shared pages fail to load on older browsers
Object.hasOwn is unavailable before Chrome 93 and Safari 15.4, and
es-toolkit calls it directly from isEqualWith, which useActionContext
runs on every render. Add a polyfill applied at module scope, ahead of
the other imports, so it covers dependency evaluation and first render.
Fixes OUTLINE-CLOUD-D0W
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Define the polyfill as non-enumerable to match the native property
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Resource timing spans made up ~84% of all spans sent, driven by the number
of code-split chunks loaded per pageload. Filter them out along with pageload
connection phases and performance mark/measure entries, and halve the traces
sample rate.
Single-letter shortcuts such as "m" to move a document were still active
while a menu or dialog held focus, competing with the control's own key
handling. Generalizes the existing text input check to cover any element
inside a widget that handles its own keyboard input.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Error names were mangled by the production build and 502 responses often
have an empty body, so these were reported without a usable title. Errors
now carry an explicit name, the message includes the endpoint, and 502s are
grouped per endpoint.
* wip
* generalize
* refactor
* Extract SearchResultIcon for command bar results
Both search action builders rendered the same document icon inline. Move it
into a shared component alongside the other command bar pieces, forwarding
size so the command bar can continue to size icons via cloneElement.
Also drop the redundant charAt(0).toUpperCase() on the initial, as the Icon
component already normalizes it.
Co-Authored-By: Claude <noreply@anthropic.com>
* PR feedback
Prevent same doc showing twice in cmd k
Improve result ordering in main app command bar
Refactor to flattenTree
* Upgrade Fuse to 7.5.0, use workers
* fix: Re-register search actions when index is enriched
Include result contexts in the command bar registration key so that
snippets refresh when the same documents are enriched, and only mark a
server search as cached once its results are actually fed to the index.
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
* CMD+enter to open in split view
* Fall back to normal navigation when location state is present
Location state cannot be represented in the split query parameter, so
opening in the secondary pane would silently drop it.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Adds the ability to open a second route alongside the current one:
- The secondary route is stored in a `split` query string parameter so
that reloading the page hydrates both panes.
- The secondary pane runs in its own in-memory router kept in sync with
the query parameter, so links followed inside the pane navigate the
pane rather than the primary route.
- Navigation while a split is open preserves the split, is directed to
the focused pane, and routes that cannot render in a pane (such as
settings) close the split.
- The focused pane is shown with an accent outline, updated as panes are
clicked or focused, and keyboard shortcuts only apply to the focused
pane.
- "Open in split view" added to document and collection menus and the
command bar.
* fix: Stale CSRF token sent on request retries and form submissions
The CSRF token cookie is rotated by the server on every safe request, but
ApiClient read the cookie once when a request was prepared and fetch-retry
reused the same headers for every attempt. Any rotation between preparation
and a retry (e.g. a concurrent GET in another tab) caused the double-submit
check to fail with csrf_error.
- ApiClient now re-reads the token cookie immediately before each network
attempt, so retries always carry the current token
- Form now reads the token at render and refreshes the hidden _csrf input
from the cookie during submit, replacing the useCsrfToken 1s polling hook
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fGhLu7zQyLdkRCx5EkYC5
* chore: Remove ApiClient test file
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fGhLu7zQyLdkRCx5EkYC5
* feat: Allow routes to opt out of CSRF token rotation
The CSRF token cookie is rotated on every safe request, which causes
in-flight mutating requests prepared with the previous token to fail the
double-submit check. High-frequency endpoints such as attachments.redirect,
hit for every inline image while reading a document, rotate the token
constantly for no benefit.
attachCSRFToken now sets the cookie after downstream middleware has run,
allowing routes to opt out of rotation via the new suppressCsrfTokenRotation
middleware. Suppressed routes still issue a token when the client does not
already hold a valid one. Applied to the attachments.redirect GET route.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fGhLu7zQyLdkRCx5EkYC5
* feat: Suppress CSRF token rotation on files.get
Like attachments.redirect, files.get is requested for every inline image
stored locally and has no need to rotate the CSRF token cookie.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fGhLu7zQyLdkRCx5EkYC5
* docs: Correct suppressCsrfTokenRotation comment
Requests already dispatched carry the previous cookie and header together
and still pass the double-submit check; rotation only races requests that
read the token before rotation but are sent after it.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fGhLu7zQyLdkRCx5EkYC5
* docs: Simplify comments
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fGhLu7zQyLdkRCx5EkYC5
* revert: Remove CSRF token rotation suppression
The api router is mounted before attachCSRFToken in the middleware chain,
so API responses never rotate the token cookie and the suppression on
attachments.redirect and files.get had no effect.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fGhLu7zQyLdkRCx5EkYC5
---------
Co-authored-by: Claude <noreply@anthropic.com>
* 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>
* fix: Retain location state when clicking on hash links in doc and TOC
* fix: Pass explicit location fields when navigating to hash links
Avoid spreading history.location (which carries internal fields like key)
and preserve the href's query string for absolute same-path links.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Refactor to patchLocation helper
---------
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>
* refactor: Decouple ApiClient from auth store and document its public surface
Move logout policy out of the transport layer: ApiClient now notifies a
registered handler on unauthenticated responses (401 / suspended 403) instead
of calling stores.auth.logout directly, breaking the AuthStore -> client ->
stores import cycle. AuthStore owns the logout flags and registers the handler.
Also add JSDoc across the public surface (setShareId, fetch, get, post, client).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor: Extend request deduplication to PUT via shared helper
Extract the in-flight dedup logic into a private deduplicate() helper and route
both post() and the new put() through it. The dedup key now includes the HTTP
method so a POST and PUT to the same path can't collide. Multipart uploads
continue to bypass deduplication.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Improve types
* refactor: Improve ApiClient type safety and address review feedback
- Add a Method union ("GET" | "POST" | "PUT") for fetch/deduplicate, replacing
the loose string type. Narrowed to methods whose bodies are actually
serialized, so callers aren't given false support for PATCH/DELETE.
- Type previously implicit-any locals (modifiedPath, urlToFetch, isJson).
- Extract an ApiErrorResponse interface for the parsed error payload.
- Register the unauthorized handler before fetchAuth() so a 401 on the initial
auth request triggers the logout policy.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* wip
* Remove obsolete snapshots
* simplify
* chore(test): Convert mocks to TypeScript and tighten fetch mock types
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Remove unneccessary patches
* Migrate to msw instead of custom fetch mock
* Address PR review comments
- Split chained vi.useFakeTimers().setSystemTime() into separate calls.
- Switch test setup to dynamic imports so EventEmitter.defaultMaxListeners
assignment runs before module init (static imports were hoisted above it).
- Drop redundant NODE_ENV guard in monkeyPatchSequelizeErrorsForJest; its
sole caller already gates on env.isTest.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* chore: Replace lodash with es-toolkit
Migrate all direct lodash imports to es-toolkit/compat for a smaller,
faster, lodash-compatible utility library. Transitive lodash usage from
other packages remains unchanged.
* fix: Restore isPlainObject semantics in CanCan policy
The lodash migration aliased `isObject` to `lodash/isPlainObject` and
the codemod incorrectly mapped the local name to es-toolkit's `isObject`,
which also returns true for arrays and functions. This caused condition
objects in policy definitions to be skipped, breaking authorization
checks across the codebase.
* fix: Restore unicode-aware length counting in validators
es-toolkit/compat's size() returns string.length, while lodash's _.size()
counts unicode code points. Switch to [...value].length to preserve the
previous behavior so multi-byte characters like emoji count as one.