Commit Graph
28 Commits
Author SHA1 Message Date
DarkSky bcf9736834 perf(desktop): reduce favorite drag and reorder work
Read favorite anchors by key. Skip writes for unchanged placements.
Keep document views when only the favorite order changes.
Set all favorite flags when the first write copies legacy favorites.
2026-12-05 14:45:31 +09:00
DarkSky fdd43a21a1 feat(store,client,desktop): store favorites in userdata table and reorder in sidebar
Store document, folder, collection, and tag favorites in the userdata$<uid>$favorite table with fractional indices and soft-delete removal.
Fall back to legacy docProperties favorite flags when no favorite table exists, and copy them into the table on the first favorite write.
Load and persist the favorite table across SQLite read-write sessions, read-only workspace opens, Web Desktop IndexedDB stores, and cloud sync.
Render and expand favorite documents, folders, collections, and tags in the desktop sidebar Favorites section apart from the Organize tree.
Add menu actions to add or remove favorites and drag reorder for top-level Favorites rows without changing db$folders order.
Copy the database to a separate path before writing a test -wal sidecar in sqlite_wal_blobs to avoid close races.
2026-12-05 10:51:39 +09:00
DarkSky 350fec7b01 feat(desktop): add interactive workspace settings, properties tab, backup export, and template badge 2026-12-05 07:04:56 +09:00
DarkSky 7ebdec91c7 fix(desktop): preserve database backlink order and limits
Keep discovery order when database names compare equal. Count rows that
link to their own document before the search removes them.
2026-12-05 06:30:02 +09:00
DarkSky 438c5cff16 feat(editor,hosts): add create-linked-doc conversion with subdoc persistence
Page FormatToolbar `Create Linked Doc` opens the `Create linked doc` title
dialog. The dialog shows the first block as the title when that block is a
heading. `Confirm` moves the whole blocks that the selection touches, with
their subtrees and all their properties, into a new linked page. Code
text, table and database cells, marks, and inline references stay intact.
It puts an `affine:embed-linked-doc` card in their place. A blank title
gives `Untitled`. `Cancel`, `Escape`, or a press outside the dialog write
nothing.

The Edgeless `More` menu adds `Turn into linked doc` for one unlocked
note. This puts an `affine:embed-synced-doc` card with the frame, index,
and connectors of the note in its place. The menu also adds `Create linked
doc` for other unlocked selections. This moves the items, selected notes
included, into a new Edgeless document in their paint order. Then it puts
a 364 x 390 `vertical` card at their center. Both actions use the same
title dialog. Each conversion is one undo step in the source document. The
open-document group of the menu comes before the clipboard group. A menu
that does not fit scrolls its rows with the wheel and does not cover the
toolbar or the creation toolbar. `PageDocSession::export_block_tree`
exports a block subtree with every property for these copies and for
Edgeless copy and clone.

`WorkspaceDocDirectory::seed_created_doc` gives the complete Yjs V1 state
of a new document to the host, so that the content persists. The desktop
host replaces the initial blocks of the store with the seed blocks through
`PageDocSession::replace_blocks_update_v1`. It queues the change for the
connected session. The desktop directory keeps the snapshot of each loaded
document, and of a seeded document that the store does not have yet, so
synced cards show the content after a refresh or a reopen. The client
directory queues the seed with the pending updates of the workspace
database (`enqueue_pending_update`). The mobile host keeps the seed as the
cached CRDT state. The mobile bridge adds a document that the shell
created to the workspace root before it merges the content. New mobile
document IDs come from the intent, or from a random value, for each
workspace. They never reuse the ID of a document in the trash.
2026-12-05 01:01:17 +09:00
DarkSky aed2556c4b perf(desktop): read sparse custom property rows
Scan each row for fields with a current property definition.
Keep a weak reference to the directory so it drops with the session.
2026-12-05 00:37:35 +09:00
DarkSky 84fa64fd2d feat(collection): match custom property filters
Saved collections and the rule preview now match workspace custom
properties of the text, number, checkbox, and date types. The rules are the
same as the property filters of the web client.

- An unknown or deleted property, a type without filters, or a method that
  does not apply to the type is an error, as in the web client.

- Compare numbers as JavaScript Number does. A document without a value is
  NaN, so no number comparison matches it.

- All filter scopes share one source of custom properties. A filter reads
  the property type and the value from it when it matches a document.

- The document views, the sidebar rows, the saved collections, and the
  preview read the property tables again when their revisions change. A
  change that no store command made also shows at once. Only a filter by a
  custom property causes a read of the property tables.

- Add YjsTableDoc::for_each_row. It reads only the fields that the caller
  asks for, so other fields of a row cause no copies.
2026-12-04 23:17:18 +09:00
DarkSky 5384a7074e feat(desktop): add collection editor with docs and rules modes
Add the `Pages | Rules` collection editor modal, rule filters (including
local calendar day `Created`/`Updated` evaluation via `LocalZone`,
viewport-clamped scrollable filter menus with full keyboard navigation,
and `Reset` input state synchronization), and `NavigationEdit::UpdateCollection`
CRDT persistence.
2026-12-04 16:33:29 +09:00
DarkSky 8319361c3c feat(desktop): add sidebar drag, peek width, and share modes 2026-12-03 20:32:17 +09:00
DarkSky 0a56c8e396 perf(store): Limit share destination and collection reads 2026-12-03 12:42:12 +09:00
DarkSky be6ba2e561 perf(desktop): check navigation list presence
Skip definition reads when a navigation edit only checks for a list.
2026-12-03 11:05:15 +09:00
DarkSky e78fc17345 fix(store): preserve concurrent workspace navigation edits
Initialize shared root lists and keep legacy navigation fields during migration.
Replace collection rows so concurrent renames and shares can merge.
Seed the desktop showcase with tag definitions and collection rules.
2026-12-03 08:25:31 +09:00
DarkSky 0d86f57d7c feat(desktop): restore the workspace sidebar
Keep workspace controls and primary navigation outside the scrolling tree.
Use the platform text input handler for sidebar names.
Keep collection entries as plain objects and merge concurrent edits by ID.
2026-12-03 01:54:46 +09:00
DarkSky 445a1092e9 feat(desktop): keep Web Desktop workspaces in IndexedDB
Read and write each workspace through its IndexedDB v3 store.
Keep document edits and deletions in order across retries and reloads.
Seed empty workspaces under the startup lock and release it if a write
cannot start or the connection closes.

Wait for pending transactions and read the stored clocks before each
retry. Cancel queued retries when the connection closes. Compact a
document only when its snapshot and all source updates still match.
2026-12-02 15:10:57 +09:00
DarkSky 3846e325a3 perf(store): advance pushed_clock from row slots and reload evicted docs
SQLite is now the only clock writer for document updates. Each row takes
the event time or 1 ms after the document clock, whichever is later. The
session no longer keeps its own copy of the clock and gives SQLite the
event time of each update.

Each committed row reports its slot: the document clock before the write
and the row time. A row that the server holds moves pushed_clock when
the row took the slot right after the current pushed_clock.

A row from the server holds this proof when SQLite writes it. A local
row holds it when the server acknowledged its push and every earlier
push of the document.

The session keeps the slots of the other committed rows until the server
holds them. The flush checks only peer_clocks and clocks in its write
transaction, and it reads no row data.

Thus a remote update on a pushed document that the session never opened
moves pushed_clock in the same transaction. The next start no longer
loads and pushes that document again.

A row of another writer between two own rows stops pushed_clock. When
the server holds the whole in-memory state of that document, a content
check runs after the commit in one deferred transaction.

The same transaction reads the rows and writes pushed_clock. If another
connection writes first, SQLite returns SQLITE_BUSY_SNAPSHOT, the
transaction rolls back, and the next flush tries again.

A SQLite-backed session drops the staged broadcasts of the oldest
unknown document above the 64 document or 1 MiB limit. It now keeps the
ID of that document in a queue of up to 1024 IDs. The next flush looks
up these IDs in SQLite in one query.

A document that another writer added becomes a disk document that the
session loads and reconciles with the server, so the dropped changes
come back. The flush drops the other IDs.

On a page with 10,000 blocks, the flush after 20 acknowledged edits
takes 7.5 ms instead of 432 ms. The flush after 50 remote updates takes
12.3 ms instead of 1,024 ms.
2026-12-02 06:09:18 +09:00
DarkSky 4bcbca66cb perf(store): tighten blob liveness, sync queues, and share ingest
Add SqliteDocStorage::has_active_blob to check blob existence without
reading blob payload overflow pages during ingestion.

Remove the redundant pre-check loop for generated media block IDs and
retry only when PageDocSession::insert_block reports a duplicate key.

Store SpaceSyncEngine outbound items in a VecDeque, peek before send in
WorkspaceSession, disconnect immediately on send failure, and clear
stale frames on disconnect.

Drop passive remote broadcasts for unknown documents without local
baselines or active loads in an in-memory session, bound in-flight load
staging with a reload flag, and clear load leases on failure,
disconnect, or deletion.

Another writer of the same SQLite file can add a document after a
session opens. Thus a SQLite-backed session stages passive broadcasts
for unknown documents, up to 64 documents and 1 MiB.

The next flush persists the broadcasts for documents that SQLite has
and drops the others. Above the limits, the oldest document loses its
staged broadcasts and needs a reload.

Split share receipt persistence into a sibling module and reject shares
targeting tombstoned documents before any write.

Keep only the written sidecar keys and their previous entries for
rollback. When COMMIT fails, take a new write lock and read the
sidecar again.

Restore only the keys that still hold this attempt without a committed
import. Thus receipts that another writer committed after SQLite
released the lock stay.

Migrate a legacy receipt of a permanently deleted document without a
witness, so the migration does not recreate its doc properties row,
and count that receipt as committed while the document stays deleted.

Reclaim oldest complete quarantine groups in ShareDiskInbox when old
quarantine files block valid batches under the 128 MiB cap.
2026-12-02 03:20:04 +09:00
DarkSky 6dbd463e67 feat(frontend): connect workspace sync to the native shells and fit embedded editors 2026-12-01 23:05:25 +09:00
DarkSky 15a7ac42fe perf(client,store): remove hot-path copies, scans, and redundant queries in sync and storage
Remove unnecessary allocations, scans, and repeated SQLite queries across document sync, media ingestion, and workspace table storage:

- Replace the full-page snapshot read and ID set scan in `next_available_media_block_id` with bounded O(1) read-only lookups against the root `blocks` map, keeping explicit block IDs in `ingest_media_into_doc_session` strict.
- Avoid cloning broadcast update payloads when a document is not in `LoadingRemote`, isolate per-update apply errors across live broadcasts and staged `DocLoaded` replays while triggering a single reconciliation and holding `remote_ts` on failure, skip unmanaged entries during timestamp sync, remove the unused `observed_remote_ts` state, and unify root, table, and page reconciliation dispatch in `doc_sync`.
- Encode `YjsTableDoc` state vectors and diffs directly via `y_octo::Doc::get_state_vector` and `encode_state_as_update_v1` instead of round-tripping full V1 updates.
- Cache per-document tombstone checks and monotonic clock watermarks within a single `BEGIN IMMEDIATE` write transaction in `sqlite/doc.rs`.
- Replace the two-query in-memory `HashMap` join in `list_unpushed_doc_clocks` with a single SQLite `LEFT JOIN` query while preserving `NaiveDateTime` comparison semantics.
2026-12-01 20:50:32 +09:00
DarkSky 4057255c50 feat(store,client): add DocSyncCoordinator per-doc sync state machine, content-checked pushed_clock, lazy unpushed subdocs, and sidecar share receipts 2026-12-01 17:13:20 +09:00
DarkSky 5737334704 perf(store): move owned blob bytes into the set_blob query
The set_blob function bound the payload by reference. The sqlx encoder
then copied the full payload into a new buffer.

The function now moves the owned key, data and mime values into the
query arguments. The SQL, the upsert behavior and the public signature
do not change.

A new single-test binary counts Rust heap requests with a global
allocator. It also checks insert, overwrite, soft delete and revive.

For an 8 MiB payload, the old code requested 8,393,257 bytes in one
set_blob call, with one block at or above 1 MiB. The new code stays
below 64 KiB and makes no block at or above 1 MiB.
2026-12-01 13:23:55 +09:00
DarkSky cfbfed3211 feat(store,client,android,edgeless): atomic draft persistence, share inbox orphan sweep, and lazy doc hydration 2026-12-01 10:05:23 +09:00
DarkSky f21fa487cf feat(mobile): add atomic 0.27.5 share block ingest, deterministic probe lifecycle, and durable share inbox 2026-11-30 13:41:09 +09:00
DarkSky a6bb03e702 feat(editor): restore 0.27.5 mobile keyboard toolbar, native previews, and fold CRDT codecs 2026-11-27 08:18:25 +09:00
DarkSky 65a2c9b097 refactor(mobile): remove duplicated logic across store and hosts
Remove eight duplicated or defensive code paths across affine-store,
affine-client, affine-mobile, and the web, iOS, and Android hosts:

- Remove explicit create recovery journals in store and client, and
  require WorkspaceDb::from_root_update_v1 to receive initial db$*
  tables at construction time instead of returning DbTableNotResolved.
- Consolidate auth protocol parsing, url::Url canonicalization,
  legacy_storage_endpoint_key (unbracketed IPv6 for 0.27.5 storage
  keys), chrono RFC3339 UTC Z normalization, Bearer checks, and
  permanent error codes into affine_store::auth while keeping iOS and
  Android 0.27.5 storage formats.
- Replace the duplicated legacy storage engine in affine-ios-host with
  affine-legacy-import, preserve malformed affine-local-workspace raw
  strings in one place, propagate iOS write-back serialization errors,
  delegate Android sentinel evaluation and probe filtering to Rust via
  a single JNI entry, and remove hardcoded Swift and Kotlin key lists.
- Remove the pure JS Yjs v1 decoder from hosts/web/src/idb-storage.js,
  expose a safe Rust wasm-codec cdylib from affine-store reusing
  merge_crdt_updates_v1, share a strict wasm-scalar-rpc.js loader with
  preview workers, wire crdt-wasm-client through index.html,
  worker-loader, host.js, stage-preview-workers, CI, and real-browser
  IDB E2E, and migrate real Yjs v1 fixtures to affine-store tests.
- Remove the 12-iteration blind SQLite retry loop in sqlite/doc.rs
  while preserving single-row empty-update registration.
- Upgrade SqliteDocStorage::checkpoint_passive to return WAL counts and
  remove duplicate maintenance pools from iOS and Android hosts.
- Remove top-level mirrored workspace fields and workspace-switch
  cloning in MobileAppState, and use generate_key_between for ordering.
- Remove pixel-fallback selection drag paths in iOS and Android hosts
  so text-layout endpoints remain the single drag authority.
2026-11-27 06:55:48 +09:00
DarkSky d63b1c7d3b feat(frontend): add IDB v3/V1 store, legacy import, and L3 client core
Add the Wasm IndexedDB v3/V1 storage model, cross-tab BroadcastChannel codec,
frozen v0.27.5 REST and GraphQL request/response codecs, and SQLite inbound
sync batch persistence in affine-store.

Add the pure-Rust affine-legacy-import crate for allowlisted Capacitor WebView
localStorage parsing, positive sentinel validation, and rollback-window
writeback serialization.

Add the device-neutral affine-client L3 domain crate with HostBridge,
ServerRegistry (enforcing F3 on Web hosts), AuthController,
StoreBackedDocDirectory (closing root registration, anti-resurrection, and
restart recovery invariants), workspace domain services, exact substring
weighted search, 25-language i18n catalog, and production PlatformAccessibility
first-frame semantic root entry.
2026-11-27 06:55:48 +09:00
DarkSky ed72cca4a3 feat(mobile): deliver S1 thin hosts, Mermaid font measurer, and release probes
Add thin Web, iOS, and Android mobile hosts, harden the blocksuite-preview
Mermaid renderer and Wasm exports, and add S1 release performance probes
with CI artifact and native host linking gates.

- Preview: use FontPoolWidthMeasurer with variable-font HVAR weight
  instantiation, integer pixel ceil widths, front-matter theme injection,
  high-contrast Light and Dark palettes, premultiplied RGBA PNG compositing,
  and Wasm theme parameters.
- Probes and CI: add s1_sqlite_probe and s1_probes release tests, record
  measured latency and peak RSS in BENCHMARK.md, add timeout-minutes on all
  np-mobile jobs, upload s1-probes-artifacts, and link Android NDK .so,
  kotlinc Activity, and iOS Simulator swiftc executable in CI.
- Web host: use an offscreen canvas GPU probe, add OAuth redirect-loop and
  runtime GPU loss guards, restrict embed URLs and sandbox tokens, match
  /api/auth/captcha Turnstile headers, and launch four independent ES module
  Blob workers pinned to site root.
- iOS host: add affine-ios-host staticlib crate implementing all C-ABI
  functions with surrogate-pair safe UTF-16 editing, weak DisplayLinkProxy,
  absolute ime_bottom contract, and in-memory LegacyCapacitorSchemeHandler.
- Android host: implement hand-written JNI bridge with absolute ime_bottom
  logical-dp conversion, predictive and legacy back gesture handling, and a
  pure Android platform SDK MainActivity and LegacyLocalStorageProbe.
2026-11-27 06:55:47 +09:00
DarkSky eff3ff6d56 feat(store): integrate affine-store into frontend workspace and harden sync
Integrate `packages/common/store` (`affine-store`) into the unified
`packages/frontend` workspace and close cross-client compatibility and
crash-recovery invariants against `0.27.5`:

- Encode page creation identity via `PageIdSource` and `CreateDocId`
  (`DerivedFromOp` vs `Explicit`), derive deterministic 10-character
  URL-safe NanoIDs from `(space_id, op_id)` without sidecar tables or
  extra keys in shared Yjs `meta.pages`, and reject `page_id` collisions
  with the root `space_id`.
- Keep `DocMode::Page` writing only the root document, require
  `db$docProperties` to be resolved before non-`Page` creation
  (returning `StoreError::DbTableNotResolved` so retry intent survives
  restarts), gate explicit non-`Page` crash-replay backfill on a
  client-local `export_explicit_create_journal` /
  `import_explicit_create_journal` record so legacy `0.27.5` pages
  without `DocProperties` rows keep `DocMode::Page`, preserve existing
  live or soft-deleted `DocProperties` rows independently of root page
  repair, and start `SqliteDocStorage::push_updates_batch` with
  `BEGIN IMMEDIATE` to prevent `SQLITE_BUSY_SNAPSHOT` on pooled WAL
  connections.
- Capture unacknowledged `in_flight` and deferred `JoinDocs` updates in
  `SpaceSyncEngine::snapshot()` ahead of `offline_queue` while keeping
  live local writes gated on `waiting_for_id_converter`.
- Wire `vars.NP_ALLOW_PERF_BOOTSTRAP` in `native-playground.yml` and
  document the three `perf/accepted.json` lifecycle actions in
  `packages/frontend/AGENTS.md`.
2026-11-27 06:55:47 +09:00
DarkSky 6f9f1cace5 refactor(workspace): dissolve native-playground into domain directories 2026-11-27 06:55:47 +09:00