Commit Graph
37 Commits
Author SHA1 Message Date
DarkSky 053180699a fix(editor): restore page block shortcuts, horizontal format bar, and narrow More creation items
Restore page drag-handle clicks to select whole blocks with the standard
horizontal FormatToolbar, remove the custom vertical block menu and deprecated
Toggle List creation entry, dedent blocks on Mod+Backspace instead of deleting
them, add Mod+Shift+L/E/R text alignment and Mod+Alt/Shift+Up/Down block move
shortcuts using the document-order start block across forward and reverse
selections, and include Create Table and Create Linked Doc in the narrow
FormatToolbar More menu.
2026-12-05 04:01:00 +09:00
DarkSky 2e383e1127 ci(np): trim headless harness build and align desktop export and search
Build only bs-harness and touch_dispatch in the headless Linux render step.
Expand the WebAssembly Data snapshot prefix check from 226 to 248 prefixes.
Extract ExportIcon, ExportToHtmlIcon, ExportToPngIcon, ExportToMarkdownIcon, ImportIcon, and PrinterIcon from @blocksuite/icons.
Use the official export icons in the header export menu and hide Export to PDF by default.
Remove document count labels and modifier split routing from Quick Search tag and collection rows.
2026-12-05 03:23:04 +09:00
DarkSky 25a5e8f9ca test(frontend): check Explorer snapshot IDs and limit wheel diagnostics
Check Explorer snapshot IDs in the Wasm data section.
Limit wheel diagnostics to one second. Keep the original error if diagnostics fail.
2026-12-04 21:55:43 +09:00
DarkSky 575b2fdddf feat(editor): add canvas document opening, table conversion, and URL autolinks 2026-12-04 19:13:57 +09:00
DarkSky a5e7ec4549 ci(frontend): check 215 snapshot prefixes in production Wasm
Add 38 snapshot prefixes for the collection editor, properties, header
dialogs, overlays, and block controls to ZERO_IN_PRODUCTION after the
existing 177 prefixes. Check that production playground and desktop Wasm
files have zero matches, and add Section 11 unit tests.
2026-12-04 17:33:09 +09:00
DarkSky 67369ef84c ci(frontend): expand snapshot coverage in production Wasm 2026-12-04 14:15:53 +09:00
DarkSky 5968d54aaa ci(frontend): ratchet 83 snapshot prefixes in production wasm
Add 15 verified desktop sidebar, outline, trash, journal, and resize snapshot prefixes to ZERO_IN_PRODUCTION.
Check uniqueness and non-redundancy across the added prefixes in unit tests.
Update packages/frontend/AGENTS.md to list desktop source liveness alongside BlockSuite crates.
2026-12-04 07:44:17 +09:00
DarkSky b817bd251d refactor(frontend): tighten harness gate, ratchet prefixes, and move icon
Check (package, kind, name) tuples for harness Cargo targets in check-invariants.sh. Duplicate target names of another kind now fail the check.

Add desktop.app_tabs.tab., desktop.split.resize., and desktop.explorer.group. to ZERO_IN_PRODUCTION. Update the snapshot prefix test count to 68.

Extract PresentationIcon into ui_tokens::icons::PRESENTATION. Replace the inline SVG in edgeless/present.rs with that static icon definition.
2026-12-04 06:09:28 +09:00
DarkSky 0bfbaf111c ci(frontend): Run harness-only tests and list iOS Simulators during the build 2026-12-04 02:28:30 +09:00
DarkSky c7f075a79c feat(playground): add editor fonts and presentation fullscreen 2026-12-03 21:45:06 +09:00
DarkSky a5090f2576 perf(desktop): reuse Wasm editor builds and strip snapshot IDs
Use the same editor features in Desktop and Playground.
Keep calendar and settings snapshot IDs in harness builds.
Check ten more snapshot prefixes in production Wasm.
2026-12-03 19:34:05 +09:00
DarkSky 241210c222 chore(frontend): guard desktop snapshot prefixes
Scan production Rust files under the desktop crate for snapshot prefix
liveness. Add the six desktop prefixes to the WebAssembly Section 11
zero-hit gate. Add unit tests for desktop source liveness, test
module filtering, and WebAssembly section matching.
2026-12-03 09:18:21 +09:00
DarkSky ea73ac3757 ci(frontend): speed up native verification
Use the Desktop leaf path to skip unrelated mobile jobs and the Metal render.
Check both production Wasm bundles for leaked snapshot prefixes.
Remove iOS host archives before cache save and cache the Kotlin compiler.
2026-12-03 06:01:03 +09:00
DarkSky 24ed5ec97f fix(editor): keep dynamic snapshot IDs out of production Wasm
Add `ui::SnapshotId` and the `ui::snap_id!` macro. Under `harness`, the
macro formats its arguments into the ID.

In other builds, `SnapshotId` has zero size. The macro type-checks its
arguments in a branch that never runs, so no ID text gets into the
binary.

`SharedString` gets `From<SnapshotId>`, so `snapshot` keeps its
signature and literal IDs need no change.

The toolbar icon button, the toolbar menu row, the context menu row,
the block menu row and the image lightbox control take a `SnapshotId`.
A caller that gives a plain string does not compile.

Remote cursors and selections, presence badges, the doc panel, the
record sheet and the block toolbars now build their dynamic IDs with
`ui::snap_id!` instead of `format!`.

`check-snapshot-prefixes.mjs` checks the prefixes of these IDs and
accepts more than one Wasm file.
2026-12-03 03:32:46 +09:00
DarkSky 4ea9100aee fix(edgeless): cache the first Page Note and check snapshot conditions
Store the first Page Note position when the header index rebuilds.
Read that position when the canvas draws the header.

Pass each required view path as a separate argument. Ignore Rust
comments and literals when matching test module braces. Reject
harness and mixed test conditions on file module declarations.
Keep the Wasm PDF module available to native unit tests.

Model: GPT-6.2 Sol.
Tests: Python, Cargo fmt, Clippy, and Cargo unit tests.
2026-12-03 02:19:52 +09:00
DarkSky 73c4150dc4 perf(edgeless): reuse the note header index across frames
The Edgeless note header pass walked the root tree on each frame. It
rebuilt two maps, copied the page title and formatted element ids.

- Keep a NoteHeaderIndexCache in EdgelessCanvasState. The document
  epoch, the page id, the document revision and the snapshot
  allocation key the index. A frame without header candidates returns
  at once.

- Collect the Frame title pills only for an expanded Page Note header.
- Use static element id prefixes with a stable FNV-1a hash of the
  block id.

- Format snapshot ids with format_args at each snapshot call. Release
  builds then keep no snapshot id text. Remove the SNAPSHOT_IDS cfg!
  constant.
- Split chrome/note_header.rs into mod.rs and paint.rs.

The fold reads the note lock and the lock of each parent Group from the
current snapshot when it writes. A lock change after the last paint now
applies. A visited set stops the walk on a Group cycle.

check-invariants.sh now also rejects cfg! macros and multi-line cfg
predicates that name the harness feature or test.
2026-12-02 23:44:39 +09:00
DarkSky a3a7496b4c perf(blocksuite): eliminate snapshot ID leaks and table/toolbar hot-path work
Remove harness snapshot ID literals from production Wasm Section 11 across 36 prefixes.
Extend `check-snapshot-prefixes.mjs` to lock those 36 prefixes and bare container IDs at zero.

- Clip table grow preview to visible viewport rows and columns in one pass.
- Defer page table cell focus label formatting behind lazy evaluation.
- Compare derived four-state table edge zone on pointer hover to skip center redraws.
- Reuse shared `toolbar_chrome` geometry constants and color tokens in edgeless chrome.
- Replace multi-pass selection scans and `rotate().transform_point()` math with single passes.
2026-12-02 20:36:12 +09:00
DarkSky 5465a17d33 perf(editor): defer block snapshot IDs
Format block snapshot IDs only when the harness records them.
Check live link destinations before popup actions and allow IME offset shifts for read-only actions.
2026-12-02 09:25:12 +09:00
DarkSky af83a5a38c perf(mobile): mount visible explorer rows and drop deleted documents
The mobile shell now removes a document when the document leaves the root document in the workspace session. Another session can trash and delete a document permanently. The shell then drops it from the list, the CRDT cache, the history, and the open page. Drafts that exist only in the shell stay. Documents with the same ID in other workspaces stay.

Workspace documents and CRDT caches change only through accessors. Each change gets a revision stamp that is unique in the process. These stamps key the caches for search hits, drawer sections, Explorer rows, breadcrumb snapshots, and the editor directory. A frame without changes rebuilds none of them.

A document lookup by ID now takes constant time. Explorer lists and folder lists mount only the rows inside the viewport plus a small overscan. The lists use ui_kit::VirtualList, and spacers keep the content height. The accessibility tree reads the same rows and the same window.

The bridge syncs the shell to the session by CRDT revision and by changed document IDs. When nothing changed, it reads no cached bytes. The sync timer repaints the shell only when the projection changed what the shell shows. The timer also checks that the bridge that ran the tick is still bound.

The editor directory keys its snapshot by workspace ID, docs revision, bulk revision, and locale. It refreshes in place only when all keys except the docs revision match. A workspace switch, a bulk change, or a locale change rebuilds it. The directory never lists or previews a trashed document.

The page editor reads the trash state directly. It encodes a state vector only when the document revision advances. The Explorer shows the empty trash text only for the trash target. A pending delete confirmation closes only for a document of the active workspace.

The views share one row_dir helper. The palette reads typed theme fields, and pure white uses ui::white(). The mobile-harness scale-probe command reports frame costs and work counts with 10, 100, and 1,000 documents. The invariants script checks mobile views for test branches. It links the ui-tokens test executable for the linker flag check.
2026-12-02 05:41:17 +09:00
DarkSky aec71dfe29 perf(editor): keep math and link checks off the frame path
Carry the page math flag across a text edit of one block. Compare the math state of the block before and after the edit. Keep the flag when the block had no math before. Set it when the block gets math. Clear the flag when the block loses math, so that the next frame scans the page.

Skip the scan while an equation draft or a code preview is open. Share one block test between the page scan and the edit path.

Read table cell text only when a snapshot asks for it. Builds without snapshots no longer search the page for the table or copy cell text on each frame.

Keep the last hover target in the view. Read it again when the page, the loaded document, the page text, the page titles or the read-only state change. Each view keeps its own targets. A target never goes to another page, document or view. A move inside the same link, also across wrapped lines, reads the text one time.

A move to another line of the same link moves the anchor of the waiting popup to that line. The popup keeps its timer. Confirm an open hover popup against the text one time per text revision. A rename of the target page updates the title and view choices of an open reference popup. Build the overlay scene for a hover only while a link popup is open or fades out. Find the table and canvas ancestors of a reference in one walk.

Format the block scroll bar snapshot ID lazily. Add six toolbar and popup prefixes and the page scroll bar prefix to the production Wasm prefix check.
2026-12-02 05:06:49 +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 7c96dfbabf perf(editor): stream layout fingerprints and defer overlay snapshot strings
Stream `Debug` layout fingerprints directly into `DefaultHasher` with a
trailing `0xff` terminator byte in `block_flow/{layout,surface_ref}.rs`
instead of allocating temporary `String` buffers, and add a unit test that
verifies bit-exact hash equality across block content variants.

Defer snapshot ID formatting with `format_args!` across
`overlays/code_lang_picker/render.rs`, `overlays/keyboard_toolbar/render.rs`,
and `overlays/paint_page/{mod,controls,media_controls}.rs`, borrow recent
code languages after the picker open check, reuse `palette.focus_ring` for
the picker focus border, and add `overlay.code_more_menu.` and
`overlay.code_lang_picker.item.` to `check-snapshot-prefixes.mjs`.
2026-12-01 21:50:52 +09:00
DarkSky f7dc193f9d feat(editor): unify ToolbarChrome, tooltips, page block toolbars, and table hover controls
Extract shared ToolbarChrome, Tooltip, and HoverController (500ms enter / 250ms leave with hover bridge) under blocksuite-editor overlays.

Align FormatToolbar (Turn into current-block icon and selected row, Align dropdown, score-ordered inline actions, dual-section vertical Highlight list, Create Table, More), Image inner top-right hover/selected toolbar with all four corner resize handles, Bookmark/LinkedDoc/SyncedDoc/ExternalEmbed/Callout toolbars (single-click select, double-click open), Link/Reference hover popup above inline anchor with bridge and dropdowns, and desktop Simple Table hover add-bars (a press counts as a drag only after 4 px of travel along the bar's axis, a forward drag adds at least one row or column, and a drag back to the press point or away from the table adds nothing), three-dot axis pills, and 5px column resize handles.

Unify Page and canvas media downloads onto ImageStore's single set_on_blob_download host channel (with Web anchor fallback), and show the canvas Image and Attachment Download button only when ImageStore::can_deliver_downloads() is true and non-empty blob bytes are cached for that source_id.

Compute document math presence once per page and document revision (snapshot_has_math, memoized on BlockFlow) instead of walking the whole page on every layout, and include database titles, row titles, and rich-text cells in both the math check and the per-block preview fingerprint.

Route /pdf through the media slash path so that a host without a file picker keeps the typed /pdf text, the same as /attachment.
2026-12-01 19:26:55 +09:00
DarkSky 2144304032 perf(preview): keep PDF documents open in the worker by docId
The preview workers now use a linear-memory ABI with four exports:
`memory`, `prepare(len)`, `invoke()` and `output_ptr()`. The host writes
each request into worker memory in one copy and copies each response out in
one copy. The old ABI called an export for every 4 bytes in each direction.

Rust gives out only the addresses of its own buffers, so the crate keeps
`forbid(unsafe_code)`. Buffers larger than 1 MiB go back to the allocator
after each request.

The PDF worker keeps each parsed document under a `docId` that the host
assigns. The frames are `PDF_OPEN`, `PDF_RENDER` and `PDF_CLOSE`.

The bytes of a document go to the worker once per open, not once per page.
Page pixels come back as a compact RGBA buffer that the worker transfers.

The playground bridge has one session table in `wasm_pdf_state.rs`. It
opens at most 8 documents or 256 MiB of source bytes.

To make room, the table closes least recently used idle documents, but only
when that makes the new document fit. Empty documents and documents larger
than 256 MiB never go to the worker.

The table closes a document when the view clears the last scope that used
it, also when no page request claimed it yet. A reopen that fails after a
worker restart keeps the known page count.

The table restarts the worker before the IDs run out.

The bridge no longer keeps 16 copies of PDF bytes.

Each worker event listener ignores events from a replaced worker, so a late
error of an old worker cannot stop the new one. A crash answers each sent
request once, so the count of unanswered requests stays exact.

`pdf-client.js` uses the same protocol and keeps its public methods. It
keeps the same open budget and waits for room before it sends an open.

New bytes for a known `docKey` now open a new document and drop the old
page count and pages. Before, the client returned the old page count.

Four snapshot IDs of the PDF viewer and the attachment toolbar use
`format_args!`, so the production bundle has no copy of their prefixes. The
prefix gate now checks 14 prefixes.
2026-12-01 18:55:10 +09:00
DarkSky 88343a5303 test(web,ci): verify legacy workspace readiness and guard wasm snapshot prefixes
Replace the interactive control check in the dual-shell verifier with a legacy workspace readiness check for @affine/mobile 0.27.5.

The verifier requires a valid workspace document route and a visible editor container with a mounted editor host.
It also requires the legacy shell cookie and no synthetic legacy shell object.
One page check covers these conditions, and it uses the same route parser as Node.
The verifier runs this page check again after each IndexedDB read and before it returns.
A shell that leaves the document route or unmounts the editor before it stores data fails.

The verifier loads yjs on demand so Node tests run without installed packages.
It reads only target document records from local IndexedDB and verifies root catalog and page block state.
Rows must agree with the nbstore schema, and the updates store must have its docId index.
When a fresh profile stops at the workspace home route, it reads one document ID from the catalog.
It then locks that workspace and document and navigates once to the document route.
A redirect to a different document fails the check.

The legacy CLI path now reopens the mounted document in a new tab of the same Chromium profile.
That tab blocks the welcome template, so the shell must load the workspace from IndexedDB.
The local workspace database count must stay the same.
A server that cannot serve the document route directly fails the check.
Limit Chromium browser test file concurrency to two in CI so three browser suites do not overload four runner CPUs during SwiftShader startup.

Add a zero-dependency Node script that scans WebAssembly Section 11 data segments for eleven harness snapshot ID prefixes.
The script also scans Rust sources under blocksuite/crates to confirm that every watched prefix stays active.
The source scan ignores test modules and their child modules.
Wire the source check into packages/frontend/scripts/check-invariants.sh.
Wire the binary check into .github/workflows/native-playground.yml after wasm-opt.
2026-12-01 14:42:28 +09:00
DarkSky 6f193694ba fix(web): serialize legacy document saves and share Chromium cleanup
Save the page and its catalog in one IndexedDB transaction.
Use the Chromium harness in four browser checks.
Use one 45-second DevTools handshake for the SwiftShader smoke tests.
Open each new page with one DevTools request.
Stop the process group if the browser exits before the handshake.
Use a short temporary directory if the socket path exceeds the limit.

Check the legacy control on two consecutive frames.
Report startup errors for --legacy-dir.
Wait for the OAuth configuration and provider render on /sign-in.
Run the browser regression tests in CI.
2026-12-01 11:11:27 +09:00
DarkSky 2b94d66b97 perf(editor): skip snapshot markers and reuse static icon strings 2026-12-01 08:22:39 +09:00
DarkSky c02056c82d feat(blocksuite): add inline popovers, block toolbars, and overlay polish
Add inline link and linked-doc 500ms hover popovers, dual-field text+link editing, and Inline/Card/Embed view conversion.

Extend the desktop format toolbar with inline equation, linked-doc creation, More submenu, and block-selection mounting.

Add block-level controls for code blocks (searchable language picker, line numbers, 8-line collapse), block/note LaTeX 2-step editing, image double-click lightbox, bookmark style toolbar, and callout 44px layout with emoji and 9-color toolbar.

Include targeted fixes:
- Flatten H4-H6 in touch Slash menus and hide scrolled-out desktop Slash preview cards.
- Allow Slash Copy in page_readonly mode.
- Preserve nested Y.Map background and readonly guard in Edgeless note slicer, guard locked mindmap descendants on delete, and skip dangling mindmap children.
- Consume click when dismissing active Calendar inline edit and restrict selected-day '+' visibility to touch form factors.
- Expand Page block_selection highlight to cover visible nested subtrees (skipping collapsed children) and align Move Up / Move Down icons in the block menu.
2026-11-30 18:18:41 +09:00
DarkSky 646d638354 fix(editor,hosts,web): resolve cold-start touch keyboard, link hit-testing, and collaborative unlink
- Track actual presented system keyboard inside MetalHostView.inputView, restore software keyboard on repeat prose taps after dismissal, honor iPadOS hardware Command shortcuts in Modifiers::secondary, and sync UITextInteraction mode synchronously across readonly/mode/form-factor transitions.

- Make mobile KeyboardToolbar visibility declarative on active selection so narrow-to-wide resize, selection clear, and Android cold start never leave a ghost bottom toolbar; deduct docked toolbar height in popover_viewport and forward iOS touches immediately when floating overlays are open.

- Re-validate LinkPopup against live document revisions and sub-ranges so concurrent partial title/text link edits survive Unlink, align full-width and adjacent-link hit-testing, update web-smoke link button geometry for the 11-item format toolbar, and harden preview-workers/sign-in redirect handling.
2026-11-29 07:35:58 +09:00
DarkSky 03736fe260 fix(editor,playground,ui): unify IME recomposition, ContentScope, touch gestures, and table navigation 2026-11-28 07:30:44 +09:00
DarkSky 4e66722b44 feat(mobile): mount native GPU BlockSuite editor in iOS and Android hosts
- Add orthogonal PointerKind, FormFactor, and EditorCapabilities matrix in blocksuite-editor, decoupling database_readonly from edgeless_readonly and enforcing page_readonly across command/toolbar paths
- Attach cross-platform CJK and emoji FontFallbacks to blocksuite-editor text runs so iOS CoreText and Android CosmicTextSystem render CJK and emoji glyphs cleanly
- Wire real WgpuRenderer and CosmicTextSystem into Android ANativeWindow via SwappableAtlas, deterministic ui::clock_now() dispatch_after timer draining, single-JNI UTF-16 reads, surrogate-pair composing alignment, requestCursorUpdates + Matrix CursorAnchorInfo, historical ACTION_MOVE samples, hardware keyboard/scroll forwarding, and zero shadow-buffer pollution
- Frame iOS MetalHostView and SelectionOverlayView inside safeAreaInsets, gate software keyboard responder on PlaygroundView::wants_software_keyboard and pan-slop tap detection, avoid double safe_bottom subtraction on KeyboardToolbar insets, prevent spurious UITextInputDelegate textWillChange/textDidChange echo during IME composition, yield hardware pressesBegan during marked text, and guard UIEditMenuInteraction with explicit actions
- Enable wgpu/cosmic-text for target_os = "android" in packages/ui/ui and add Linux fontconfig/freetype packages to np-mobile CI workflow
2026-11-28 06:11:09 +09:00
DarkSky f7150b2191 feat(blocksuite): add affine:database CRDT codec and Table/Kanban/Calendar views 2026-11-28 00:33:36 +09:00
DarkSky 3d7c480933 perf(preview,playground): drop unused wasm exports and serve validated web fonts statically
Gate wasm-bindgen worker exports per preview target, externalize the four bundled UI/script fonts from the web playground Wasm bundle into static web assets, and validate fetched font bytes through the text system's fontdb loader so empty or HTML fallback responses fail closed with usable-face checks.
2026-11-28 00:31:40 +09:00
DarkSky 8e0b345036 feat(editor): extract ui-tokens, ui-kit, and blocksuite-editor crates
Add the zero-dependency ui-tokens crate to export generated theme tokens,
icon definitions, and bundled font bytes without cross-tree include_bytes!
paths.

Add the domain-neutral ui-kit crate with logical geometry helpers, SafeArea,
VirtualList, SwipeDialog, and SwipeMenu state machines backed by scheduler
time and four-rate replay invariance tests.

Extract blocksuite-editor from playground with the WorkspaceDocDirectory
host port, exact substring UTF-16 highlight matching, and LTR/RTL logical
start/end block flow layout. Slim playground to the demo and harness host.
Update workspace manifests, static invariant guards, CI workflows, and
AGENTS.md files.
2026-11-27 06:55:47 +09:00
DarkSky d619bfbcda feat(preview): add pure-Rust offline preview kernel crate 2026-11-27 06:55:47 +09:00
DarkSky 0c9e634d08 feat(ui): add L0 mobile logical layout, bidi shaping, gestures, motion, web safe-area and iOS foundation
- Add logical geometry helpers on Edges, Corners, Svg, and scroll offsets, and propagate inherited LayoutDirection through Taffy and fast splice rebuilds with a zero-clone LTR fast path.
- Propagate explicit BaseDirection through LineLayoutCache and all platform shapers (Apple CoreText, CosmicText, and Web), sort visual clusters by x_start, add UAX #9 multi-line soft-wrap bidi reordering, preserve contextual Arabic joining across same-font runs, and align text truncation on shaped glyph-cluster boundaries (`UI_LOC_CEILING = 95200`).
- Add scheduler-clock TouchGestureRecognizer with tap, long-press timer wakeup, pan cancellation, pinch re-anchoring, and closed-form MotionCurve presets including SwipeMenu InOutSine and SwipeDialog cubic-bezier/outQuad.
- Replace Web four-element safe-area probing with a single hidden probe and exact per-edge float comparison, preserving non-double-subtracted IME insets.
- Align the iOS platform stub traits and PlatformInfo, update packages/ui/AGENTS.md, and add aarch64-apple-ios and aarch64-apple-ios-sim compile guards to native-playground CI.
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