5 Commits
Author SHA1 Message Date
Tom Moor ef6e51401b perf: Reduce main-thread cost of opening a document from the sidebar (#14033)
* perf: Read active models lazily in ActionContextProvider

The root provider read the active document and models during render, so
every navigation rebuilt the context and re-rendered all consumers. These
values are now getters, and overrides are merged without evaluating them.

* perf: Skip urlId scan in Store.get for UUIDs

When an id was not loaded, get() searched every item by urlId, so each
sidebar row observed the whole store. A UUID cannot end with a urlId, so
the search is skipped for UUIDs.

* perf: Stop sidebar rows re-rendering on navigation

- Track expanded nodes in an observable map, as ObservableSet.has tracks
  the whole set.
- Do not rebuild the document tree rows when the active document changes.
- Auto-expand the active path in a reaction instead of reading the active
  document during render.
- Compute active state per row, and keep row props stable.

* perf: Add useLocationSelector for persistent components

useLocation re-renders on every navigation. The new hook re-renders only
when the selected value changes, and is used where components stay mounted
across navigation. AuthenticatedLayout now keeps its portal element in
state, as it no longer re-renders after mount.

* chore: Send Document-Policy js-profiling header in development

* docs: Add render performance guidance to AGENTS.md

* fix: Check document or collection star exclusively for active state

* fix: Read location from each action context provider's own history

Nested providers inherited the root location getter, so menus inside a
split view pane read the browser route instead of the pane's route.

* fix: Expand starred collection when the active document changes
2026-10-11 15:17:01 -04:00
Tom Moor d6e555bb19 perf: Virtualize sidebar document trees (#13993)
* perf: Virtualize sidebar document trees

* fix: Hide empty state while adding a doc and scroll the active row on tree mount

* fix: Track scroll margin for sidebar trees that start empty
2026-10-08 20:42:57 -04:00
Tom MoorandClaude Fable 5 c7a580fb8c Harden shared tree utilities and add test coverage (#12924)
* Harden shared tree utilities and add test coverage

- Fix ancestors() throwing a TypeError when a node's parent is undefined
  rather than null, which is the case for nodes that haven't been
  annotated by useCollectionTrees (e.g. shared trees from the server).
- Guard against malformed parent cycles in ancestors() so a bad tree can
  no longer hang the client.
- Compute descendants() depth limits relative to the given node during
  traversal instead of relying on optional absolute depth annotations,
  which silently returned an empty list when they were missing.
- Tolerate nodes without a children array in traversal.
- Remove type assertions, add JSDoc, and add collocated unit tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vt5wWLYomgKZjfgPNk8wN4

* Address review: exclude node from own ancestors on parent cycles

- Seed the cycle guard with the starting node so a malformed parent
  cycle can never include the node in its own ancestor list.
- Widen flattenTree's parameter to accept nullish roots so the runtime
  guard and the type contract agree.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vt5wWLYomgKZjfgPNk8wN4

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-11 06:22:42 -04:00
Tom Moor bf45e97641 chore: Enforce type import consistency (#10968)
* Update types

* fix circular dep

* type imports

* lint type imports and --fix
2025-12-19 23:07:02 -05:00
Salihu 430883f186 feat: Custom emoji (#10513)
Towards #9278
2025-12-01 02:31:50 +01:00