On this page

Editor rendering and recovery

This reference describes the source analysis, renderer and persistence contracts behind the Editor controls.

Syntax analysis and editing contexts

Packages can declare uniformLineComments when one line marker or block-comment fallback applies throughout the file. Those explicit line-comment commands stay available before analysis and above its source limit. Providers with context- dependent rules wait for current host structure instead; the editor does not guess which languages are containers from their names.

Paired typing/deletion, Enter, selected-line reindent, line/block comments, structural selection expansion and bracket navigation use validated parser contexts when available, including JavaScript template interpolation and HTML script/style bodies. Reindent keeps multiline literal content unchanged and separates embedded bodies, including after an unclosed block. Block comments use the language at each selection; caret edits stay within an embedded body, and selections escaping that body leave the document unchanged.

Line comments combine per-language line markers and block-comment fallbacks in one transaction, deduplicate identical targets and preserve caret/selection direction through undo/redo. Selection expansion follows parsed words, expressions, blocks and functions before whole-line fallbacks, with validated source ranges and reversible shrink history. Bracket navigation and its decorations use the same contexts, including interpolation code and separate embedded bodies.

Host components can supply bounded structural fallbacks when a grammar is unavailable; clients consume those results or retain core plain editing. A compact spinner occupies a reserved final slot in the status bar while the current file is being prepared. Its “Preparing syntax…” tooltip and accessible label disappear with the spinner when colors or terminal plain fallback are ready; the existing status controls keep their positions. Syntax colors stay plain until grammar preparation succeeds; unsupported files never receive guessed code colors. Edit highlighting uses the same cached providers, with extensible highlight selectors and parser-protected literal/comment spans, including interpolation code and HTML script/style bodies. Tokens preserve source bytes; the DOM adapter only normalizes CRLF for textarea alignment. Highlight selectors receive the node and its cursor-provided immediate parent (None for a tree root), preserving declared node/parent/document dependencies without searching backward through wide sibling lists. Retained syntax parts use that same parent context for identity and dependency checks. Inline/Split diffs, recovery reviews, Git previews and chat diff previews request analysis of each complete source version through the same host service, then intersect syntax colors with word-change boundaries.

Source line numbers remain independent of alignment gaps; CRLF terminators are excluded while a final bare CR is preserved. PHP heredocs/nowdocs and shell heredocs preserve literal contents. PHP interpolated expressions (including their braces), shell command/parameter/arithmetic substitutions, Python f-strings and C# interpolation expose code while keeping nested literals protected, including through enclosing string wrappers. Files over 2 MiB or 65,536 bracket tokens fall back to ordinary indentation and typing. Large-file benchmarks stay on the roadmap.

The edit view retains each file’s caret, selection direction and horizontal/vertical scroll position within its project while the app is open, including when switching to a diff view and back. New files start at the beginning; changing accounts clears these positions. Database recovery also restores these positions on reload, subject to the current file’s scroll bounds.

The bundled language-family components use shared incremental grammar providers for Rust, TypeScript/TSX, JavaScript/JSX, Python, Java, C#, C++, PHP, Shell, C, Go, HTML and CSS. Trees update with Unicode-safe byte edits. Fold descriptors cover blocks, declarations and multiline comments/literals, with Python suite headers retained. Cancellation and oversized files discard stale trees; unsupported languages use lexical/indentation folding. Custom SyntaxProvider descriptors use the same update and fold policy through SyntaxDocument::with_provider.

Production frontend builds exclude editor-parser, syntax grammars and plugin runtimes. Each language-family component contains its own engines and uses the public syntax toolkit through the same SDK as community packages. Compiled defaults install offline on execution hosts. Source builds containing C grammars use the pinned WASI SDK. The browser C adapter is retained only for isolated legacy protocol tests.

HTML script/style bodies resolve installed JavaScript/CSS providers and full-file fold coordinates, including after Unicode/CRLF edits. Declared types select supported bodies; JSON data scripts and unsupported style types stay in HTML. Each provider can supply an injection selector returning validated source ranges. The shared host service bounds embedded work, source bytes and nesting depth; disabled, missing or failed child providers leave their bodies plain while preserving outer-language results.

Editing commands, structural selection expansion and bracket navigation use immutable parser contexts from the shared per-document cache. SyntaxDocument::prepare publishes one source-bound snapshot of folds, structure and tokens per source/tab width. Tab-width changes retain structure and token allocations for unchanged source, recomputing indentation-dependent folds. Consumers share immutable allocations; source updates and cancellation invalidate the cache while previously published snapshots retain their original source. Parser folds retain descriptors for unchanged top-level subtrees. The previous tree keeps node IDs alive; reused positions rebase from the new subtree origin, closing-line text is checked again and reused nodes still count toward analysis limits. External parent-owned headers use fresh extraction. Each embedded parser retains its own bounded current-tree cache, cleared with parser cancellation. Editing contexts use the same retained-tree identity and visit budget, with source-relative protected regions, interpolation holes and selection ranges. Classifiers declare SyntaxContextScope::Node (kind, flags and descendants), Parent (also the immediate parent's kind) or Document (broader dependencies). Document-dependent classifiers and chunks whose interpolation owners lie outside the subtree use fresh extraction. Built-in PHP classification uses the parent scope; other built-ins use node scope. Context assembly and lexical fallbacks still scan the complete source, and edits inside a large top-level subtree still revisit that subtree. The frontend facade also rejects changed account, file-read, source and tab-width scopes before publishing results.

Each cursor uses its own language, including JavaScript/CSS in HTML, and template interpolation code remains editable while literal text is protected. Incomplete input uses bounded lexical fallback; JavaScript template interpolation also works during incomplete typing. Contexts verify their exact source before a command can mutate history. Custom provider classifiers use the same traversal, limits and fallback policy.

Preparation and viewport rendering

The production editor uses one shared language-service facade above thin server and paired-host transports. Installed components own syntax analysis; host APIs provide generic component execution rather than language-specific built-ins. One analysis runs per active service while repeated edits replace queued source. Full snapshots and UTF-8 byte replacements carry revision and SHA-256 identity; a lost base retries once with a full snapshot. Close, eviction and host restart release component document state.

The client validates result identity, UTF-8 ranges, token coverage, folds and bracket links before publication, without parsing source again. Replies must still match the account, project, session, document, provider and configuration. Changing these scopes cancels obsolete work. Disabled, unavailable or failed providers leave source and ordinary editing intact through core plain-text rendering; there is no browser parser fallback.

While syntax is pending, context-independent declared rules remain available. Commands requiring current structure wait for that source or report unavailable structure without editing. Previously inserted automatic pairs retain their editor-owned transaction behavior while the next analysis is pending. Enter's validated closing indentation remains available until another edit or undo. Declared surrounding pairs wrap explicit selections without waiting for analysis; automatic insertion at a caret still respects the provider's context exclusions. Reusing an immutable result after inverse edits requires exact source equality and all original ownership, provider and configuration guards. The facade accepts a runtime input clock while retaining the browser clock and 12 ms budget by default. Readiness/history and explicit budget-expiry contracts use controlled clocks; they do not establish physical readiness within 12 ms. Cold input latency remains tracked in the roadmap and performance evidence. Explicit Reindent requests and comments in declared embedded-language containers wait for current host structure, then apply through the shared editor command facade. Ownership is captured before queuing the action, so an unpolled task cannot acquire another file or newer source. Single-language comments retain immediate behavior, including SQL and admitted files above the structure budget. Explicit selection expansion and bracket jumps share this ownership/preparation path, while plain source retains basic word/line selection without inventing language structure. Navigation and selection commands supersede pending structural actions even when their selections remain unchanged. Passive bracket decoration uses current source-bound results and clears when those results are unavailable. Comment menu eligibility uses completed embedded-language structure and requires support at every selection's start. Mixed selections therefore disable actions that cannot apply atomically. Reading eligibility never starts parsing; pending container actions can await their host context when invoked, while capacity-rejected containers disable those actions. JSON/JSONC, TOML, YAML/YML, INI/EditorConfig, XML build configuration and Markdown use registered grammars inside their respective language-family host components. Markdown has separate block/inline parsing and declared fenced-code languages; ordinary prose stays plain. File detection recognizes common manifest/settings names including MSBuild projects/solutions, NuGet.Config, pom.xml, setup.cfg, Cargo/Python lockfiles, Pipfile, Composer lockfiles, Git config, npmrc and env files. SQL and other unsupported grammars retain plain paint.

Cooperative plain-row fallback preserves source boundaries and cancellation publishes no partial rows. LICENSE, NOTICE and other extensionless prose stay plain.

Unwrapped edit views render an overscanned row window for syntax, line-number gutters and fold controls. The shared row-window policy receives browser geometry; projected rows retain global native UTF-16 offsets for Unicode/CRLF pointer mapping. Syntax tokens and indentation guides are reused across scrolling. Paint and cursor measurements synchronize native viewport dimensions as well as scroll offsets, so a delayed resize/scrollbar observer cannot move a cursor using stale wrap width.

Find and navigation can reveal rows outside the current paint window. Wrapped views and rows containing standalone CR also use exact measured row-height windows. Cold measurement and remeasurement use temporary batches of at most 128 logical rows and 64 KiB of source, keeping each logical row intact. An individually longer row may exceed that byte budget up to the admission cap; finer rendering within these rows remains a follow-up.

Batches release their DOM before yielding, with a frame turn every eight batches. The native input stays visible and editable until exact measurements are ready. Shared progress permits queued cursor movement to wait while preparation advances, retaining a bounded retry for stalled work. Measurement publication checks source, folds, project, account and font/width scope, and rejects a height table that disagrees with native scrolling.

Offscreen cursor-neighbor probes measure exact geometry on demand in temporary row/byte batches; no hidden neighbor paint is retained between key presses. Both-mode browser contracts move 60 distant cursors and restore their exact selections, check the actual probe limits and release, and keep persistent paint in its viewport window. Cursor motion preserves the projection revision when folds do not change.

Resize, font and styled-paint changes require fresh measurements; collapsed panels cancel pending work and restart when visible. Localized edits reuse exact heights for unchanged styled prefixes and suffixes, including row insertions, deletions and undo. Reuse checks account, project, file-read, font/width, indentation, whitespace, token styles and line-ending scope; font changes clear the cache. Large regions between disjoint edits reuse matching interior rows through exact paint equality as well; conflicting measurements for identical rows are not reused.

Browser contracts compare exact source and selections after queued arrows followed by typing, composition, paste and cut with cold versus prepared layouts in both workspace modes. Real-device input and clipboard verification remain follow-ups. Cancellable, noncomposing text insertion records event data before the browser's native edit, then commits through the shared document transaction engine after validating source, read, account, selection and folded projection ownership.

Small unbound single-cursor insertion keeps the native textarea value; trusted browser commits without folds also skip the input handler's full DOM-value read. Folded, multiple-cursor, synthetic and fallback input reconcile the installed value, using scoped surrounding text when a native window is bound. Multiple cursors use the same typing-history group. Typing declarations retain a bounded 16 KiB surrounding-text projection around the selected range start. Local byte and native offsets map to full document coordinates, including partial rows, Unicode, CRLF and folded gaps; replacing a larger directional selection still edits its complete source range.

Native origins and source/read/account/document/selection checks reject stale declarations. This bounds the retained declaration, not the textarea value or layout. The shared editor facade also captures immutable native contexts with 12 KiB of surrounding text and 4 KiB of growth headroom. Context replay borrows the source and preserves the complete selection even when the browser can hold only part of it, including directional Unicode/CRLF replacements and multiple cursors.

Source, selection, fold, document, read, project and account changes reject stale contexts. After a commit, the facade rebases the context to retain a matching browser value; composition can retain its growing value under the document admission limits instead of replacing active input-method text. Prepared larger editors on fine-pointer devices now bind these contexts to the native textarea. Binding state belongs to the workspace, so independently created facades and capture-in-chat commands use the same installed context. Source paint, clipboard and keyboard commands retain full-source coordinates; Select All and Page Up/Down operate on the document rather than the clipped window. Leaving Edit view releases the native binding; a remounted input uses full-source geometry until its prepared source extent is ready again. A generation stamp is installed after native value/selection restoration, rejecting events from older windows. Composition ownership includes read revision and account, so stale previews cannot restore snapshots into new reads or accounts. Provider metadata retains the native projection when collapsed ranges are unchanged. A bounded native probe positions the browser composition caret at the source paint point without changing the source viewport. Small files retain the trusted insertion shortcut. Initial cold layout and coarse/touch devices retain full native input until source caret, extents and touch selection are ready; physical Chrome/Edge PWA input-method verification remains pending. Document and composition snapshots share source text, logical-line indexes and prepared projections. A changed version detaches once with insertion headroom; ordinary subsequent edits reuse its buffer. Cancellation restores the committed version and its prepared projection. Recovery serialization still copies the committed source at the persistence boundary, and editing still shifts suffix bytes/indexes and rebuilds changed projections. Pointer selection adapters borrow current source while gestures retain the shared document version identity. Replacing a document invalidates its gestures even when text and revision match; unchanged document snapshots remain valid. tools/check-editor-pointer.py uses trusted Chromium mouse events to check token columns, far-right blank space and scrolled bounded Rust/C#/JSON drafts with press/move/release and insertion/undo in both workspace modes. Click and drag hits validate browser positions against measured text boundaries, including token and container fallbacks, and normalize vertical row padding to the glyph band. It does not prove physical touch selection or installed-PWA behavior. The verifier awaits editable, source-owned paint, completed recovery checks and loaded fonts before measuring gesture coordinates; failure diagnostics retain row/input rectangles and event cancellation state.

While host syntax is pending, cold views borrow plain row bodies from the existing projection instead of normalizing and tokenizing another complete file on the UI thread. Requested rows and source slices feed the same paint and measurement paths. An existing styled frame stays visible within its document/read/account scope; replacement batch measurements wait for syntax, and source pointer controls remain disabled while its paint is stale. Forced caret probes can still reconcile current source. Unavailable-host fallback preserves plain source in cooperative whole-row batches, publishing only complete current-source tokens. Plain-row updates reuse matching raw source in analyzed and fallback paths. Fallback preparation reuses a current published syntax scope. Syntax queries still copy source in some paths. Cold source geometry, long-row shaping and touch input remain unfinished.

Frontend app and browser-test links reserve a 2 MiB WASM stack for nested Leptos views. The editor erases its outer view type to reduce return-value copying; source buffers and admission limits remain independent of this stack allocation.

Prepared primary caret/selection paint and single-cursor keyboard motion use shared source geometry and Rust commands. Caret reveal uses the common scroll viewport, including offscreen rows. Prepared mouse clicks resolve measured character positions and clamp blank space past the text to the line end. Prepared clicks and drags select source carets, words or logical lines through the same Rust policy; Shift-click preserves the existing anchor.

Copy/cut use full source ranges for single selections too, preserving CRLF and shared undo behavior. Holding a drag near or beyond a viewport edge scrolls and extends the source selection vertically or horizontally, including with a stationary pointer. Mouse release or window blur stops it; pending paint is retried. Source/read/project/ account and fold changes discard active drags.

Prepared source row widths/heights now control scroll extents, reusing unchanged row dimensions after edits and retaining the source viewport's trailing padding when native scrolling clamps earlier. Source/account/syntax/layout guards discard obsolete dimensions; prepared scrolling reads no native input width/height. Physical browser size limits still apply. During prepared edits, the source viewport retains its last measured extents until replacement measurements arrive; local native scrolling cannot change that viewport. Cold/touch selection, initial cold extents and cold caret ownership still need to move out of full native input.

Direct insertion and native replay share newline normalization; rejected edits preserve source and selections. Non-cancellable input and IME map projected changes into source replacements and validate their resulting selections against borrowed prefix/insertion/suffix pieces. Replay constructs no complete replacement value; complete textarea diffing compares borrowed raw chunks between normalized CR/LF boundaries and returns source byte boundaries directly, without constructing normalized source copies or rescanning prefixes for UTF-16 conversion. Duplicate composition commits use the same borrowed comparison and leave selections/history unchanged. Complete-value comparison remains linear in unchanged prefix/suffix text. Chunks retain complete Unicode characters and never split a CRLF pair; normalization at chunk edges uses the same directional character iterator as native text generation. Cold geometry probes, cropped row paint and visual cursor measurements use this borrowed check to validate DOM text without allocating temporary normalized source strings. Ambiguous repeated-text edits retain the original selected occurrence. IME previews validate eventual secondary edits against the same byte, line and long-line limits before publishing the primary change, and failed frames restore the pre-composition source, selections and redo history.

Composition cancellation restores the committed document before publishing. Its discarded preview and restored source stay borrowed during ownership checks; only matching active views and retained project snapshots copy the restored source. The engine still retains a full committed source baseline while composition is active. Document clones share immutable history steps and transaction payloads. Appending a shared typing group copies its step metadata and transaction references, retaining the existing replacement strings; undo/redo cursors and pruning remain independent. Saved-text baselines are also immutable and shared by clones. A save acknowledgement retains the written version separately from newer edits, shares it with an active composition baseline and reuses an identical saved version. Recovery still serializes owned text at the persistence boundary.

Ownership checks, cursor counts, Select All and navigation queries borrow current source instead of cloning complete file values. Native selection mapping lives in the shared input facade; the DOM adapter supplies UTF-16 positions and reads its value only when an unbound folded view needs validation. Ordinary typing keys do not capture a source snapshot in selection dispatch. Commands, clipboard edits and search replacements publish the document's immutable source handle and return selections; native input and composition completion publish the same handle. Active content, retained file buffers, project snapshots and Find scopes share immutable editor text. Hydration and document initialization share source too; edits detach retained versions before mutation. Write and recovery transfers retain their existing owned-string contracts. Matching borrowed source validates pointer/length first, with complete byte equality for external text. Ordinary transactions validate borrowed proposed pieces before mutating the existing String, including grouped undo/redo. Growth reserves at most 64 KiB of headroom above the transaction's peak size, rather than doubling a large buffer. Affected row contexts are merged so multiple cursors rebuild a shared row once, while distant edits retain interior coordinates.

Fold rebasing uses precise edited boundaries and retains unaffected collapsed ranges until providers refresh. After an edit, a refreshed fold must match the entire rebased range to inherit collapse state. Reusing a header with a different end opens the new range, so removing a Markdown section boundary cannot silently hide the following section. Admission reuses indexed break counts for unchanged complete rows in already admitted sources, scanning inserted text and joining boundary rows. Non-admitted source retains the full scan and its error order. The index adds a break prefix and oversized-row flag per logical row; suffix updates still shift those prefixes. Embedded-language range validation shares the parser edit path’s indexed point mapping, including Unicode, CRLF and EOF after row insertions/deletions. Syntax scopes, lexical jobs and shared parser preparation retain the immutable editor source; validated host results retain the same snapshot. Components retain their synchronized source. Host toolkit calls, Git diff shaping, serialization and normalized native text still materialize source Strings. The native textarea still owns the complete projected source during initial cold preparation and on touch devices; prepared fine-pointer editors retain surrounding text instead. Remaining source materialization and retained versions still prevent complete viewport memory bounds.

Document coordinates and caches

Long-row coordinate preparation also records long runs of whitespace, word characters or punctuation. Word motion reuses these immutable summaries at exact grapheme boundaries instead of rescanning long tokens or indivisible Unicode clusters. Short runs retain the existing grapheme traversal; noncanonical carets and row crossings retain the complete-source fallback. Double-click and word-drag selection use the same category steps to find the complete source unit, including whitespace and the final unit at line end, without scanning from the start of a long row. Summaries publish only with completed coordinates and survive unchanged-row edits and undo/redo.

The shared document maintains logical-line and UTF-16 prefixes across transactions, grouped undo/redo and composition. Commands reuse indexed rows; native caret mapping binary-searches the appropriate row. Long rows retain sparse, Unicode-safe byte/native-UTF-16/character checkpoints every approximately 512 bytes. Document and folded-view offset queries and cursor line/column status scan only the tail after a checkpoint. Rows outside the rebuilt edit region retain their indexes; folded views share the same immutable checkpoints.

Parser byte coordinates use an incremental logical-line table with the same changed-row reconstruction and suffix rebasing as document coordinates. Edit points query indexed rows, and grammar paint reads those row boundaries rather than splitting the complete source again. Direct parser updates enforce the existing row limit; cancellation clears the retained coordinates. Shifted suffix records still require rebasing.

Parser fold validation queries the same indexed rows without building a complete list of row slices. The shared fold policy borrows those rows for grammar-backed documents; standalone lexical callers index once. Syntax row slices retain CR before LF so Tree-sitter byte columns and closing-line sibling checks keep their existing meaning. Lexical scans and fold-result assembly still visit the file.

Grammar paint assembles one row at a time, comparing incoming piece identities against that row's retained list. Matching rows keep their list and token allocations; changed classifications rebuild the row. This avoids temporary piece lists for the complete source, while boundary construction and the final row table still visit the file.

Ready unwrapped frames can bind bounded native surrounding text while complete row measurement is still pending. The shared input facade validates the current frame's source revision, complete native value and dimensions; the browser captures its full-source scroll extents before replacing that value. Restored windows publish their ownership stamp before scroll reconciliation, preserving the complete file's viewport. This transition rejects wrapping and active composition. Before a ready frame, and for cold wrapped or touch input, the full native surface remains the fallback.

Inside the host toolkit, lexical scanning returns source-independent structural metadata. Parser fallback and lexical folding consume this borrowed scan without copying complete files or embedded-language bodies into temporary structures. Owned editing contexts use the same scanner and region queries, including the byte/bracket limits and unavailable-context fallback. Scanning and metadata assembly still visit the source.

Long-row paint and cursor probes also share sparse grapheme/UTF-16 coordinates and cached horizontal eligibility; unchanged rows retain their allocation. Lookups scan from exact cluster boundaries instead of preparing a complete glyph array on each probe. Validated fragment paint is retained for revisited intervals (at most 16 entries and 2 MiB of HTML), scoped by document, account, read/pending ownership, projection, syntax/guide allocation, indentation, whitespace and browser shaping/layout.

Font events invalidate even when computed font text stays the same. Horizontal and wrapped rows additionally retain at most eight geometry tables with 4,096 allocated glyph anchors each, including glyph overflow beyond the logical CSS box. Newly visited intervals clone bounded source before layout, validate measured anchors, then apply the complete fragment glyph check. Wrapped slices preserve original visual-row/tab origins, logical heights and global native offsets.

Full-paragraph measurement remains the fallback for invalid geometry, oversized cluster slices, bidi paragraphs or reshaping differences. Cold height measurement supplies horizontal and wrapped paint with these anchors while they remain in the bounded cache, avoiding a second complete-row shaping pass. Eligible unwrapped styled viewport slices reuse the paragraph preparation's original run boundaries, guarded by immutable source/token/guide identity and account/project/font/metric ownership. They include the preceding original run before DOM cropping, so segmentation need not revisit the unused token prefix. The 64 KiB slice limit and exact anchor/full-fragment checks remain. Unsupported or uncached scopes retain the original segmentation path. Range crops preserve inline token/run ancestors while rebuilding absolute fragment geometry, retaining colors and italic comment styles. Ordinary cold horizontal paint waits for the active geometry probe while native input stays visible; explicit caret/movement probes can still reconcile source. Equivalent syntax results preserve proven geometry for identical styled rows; font loading advances independent font provenance even if computed font text is unchanged.

Active-line and matching-bracket decoration tasks retain only guarded source-row and native UTF-16 coordinates. The shared facade borrows current source and uses the document's sparse line coordinates; queued marks are rejected after source, selection, syntax, view or presentation ownership changes. Moving away from a bracket skips structural preparation without copying the file. Bracket-adjacent queries retain the existing parser/lexical fallback contracts.

Geometry publication checks the original source/view, font and layout epochs as well as read, account, syntax and style ownership. Retained anchors select bounded token source before HTML generation and parsing. Partial measurement failure discards those anchors and restores complete source before a fresh probe; Unicode offsets, token styles and logical extents remain intact. Unwrapped rows retain equivalent styled geometry within the same font generation without requiring a wrapped height table.

Ordinary layout reconciliation can follow equivalent syntax paint without discarding its validated anchors; actual font invalidation always discards them. Already-settled browser font readiness does not invalidate initial geometry; font loading completion and failure still invalidate it. Initial unwrapped fallback frames can paint short requested rows directly from the immutable projection before cooperative lexical preparation finishes. The shared facade bounds pending viewport paint to 128 rows and 64 KiB, with uniform row geometry; full-file measurement still waits for prepared fallback tokens. Unsupported cold viewports restore complete native text instead of moving an old plain frame onto a different source range. Active composition retains its installed mapping. Completed styled frames retain their existing pending-style policy.

Cold row-height preparation groups exact current paint keys, including token boundaries, row endings and guides. After at least two measured members agree in both width and height, the shared plan fills their remaining identical rows. Every sample in the current batch is checked before reuse; differing dimensions retain fresh measurement for that group. This reuses dimensions, not glyph anchors, and keeps the same source, account, font and layout publication guards. Distinct cold rows still require full styled measurement.

First measurement still shapes the complete row. Initial layout, uncached full-row HTML construction and native input costs remain performance follow-ups.

CRLF inverse mapping still selects the original CR, and surrogate offsets retain the existing boundary behavior. Projected text, normalized textarea text and visible-row coordinates share immutable allocations until source or folds change. Unfolded document projections share the document's source storage, coordinate table and lazily prepared visible-row table. The row table updates changed rows and shifted suffixes after each edit batch; unchanged prefixes remain in place. Retained views detach before mutation, and cold indexes do not prepare the table. Growth reserves 256 rows of headroom rather than doubling a large table; major deletions release excess capacity. Folded and bounded views keep their own visible-row and coordinate tables. LF textarea text shares the source storage too. Folded text reserves only visible bytes and moves its assembled String into shared storage. Native normalization and fixed-row eligibility query indexed UTF-16/display-break spans; full unfolded views use a constant-time query, and folded views combine only visible rows. Bounded windows inspect their own small slices. CR/LF normalization uses one pass with a source-size capacity bound. Unused projection caches release their source before edits; retained views and composition baselines remain immutable through copy-on-write. Projection provenance compares immutable allocations and document-version markers, rejecting fresh documents initialized from the same source allocation. Empty String buffer pointers likewise cannot distinguish replacements. Retained paint visibility and source-pointer readiness are separate states; the editor exposes data-editor-pointer-ready for browser checks and diagnostics. Preparing a view does not change document identity. Short-line queries and warm projection access are measured in editor performance; full String materialization and long-line query costs remain.

Both adapters retain at most eight syntax documents and 8 MiB of source, using LRU eviction. Preparation falls back beyond 2 MiB, 50,000 lines or 100,000 metadata records; bracket and embedded-body limits still apply. Wire envelopes are versioned and bounded before JSON parsing. These are preparation/cache limits, not a measurement of total editor memory or final large-file performance. Full viewport rendering and end-to-end latency/memory measurements remain roadmap work. Prepared grammar paint retains token styles on long rows within those source/work limits. Cancelled, oversized or unavailable analysis still uses the cooperative plain-source renderer; no heuristic color categories are generated.

The shared document now owns fold state independently of undo history. Commands can collapse/expand at the caret, recursively or all, and reveal a navigation target. The projection retains logical source row numbers and maps Unicode-safe byte offsets and directional selections between visible text and the full source. Native edits that cross omitted text explicitly require revealing it first. Edits open affected folds and rebase unaffected headers; stale ranges stay invalid until refreshed from the new source. Grouped undo/redo rebases the final transaction result once.

These primitives and the folding view use the shared editor facade in both modes.

Recovery contract (integration in progress)

The shared Rust recovery format and /api/projects/{id}/editor-recovery GET/PUT endpoints persist tab order, selection, per-file scroll/read-only state and document snapshots in user-scoped database settings. PUT requires the revision returned by GET; a stale revision or changed project root returns 409. Closing every tab retains a revision rather than deleting it, so an older window cannot resurrect its drafts. Project deletion removes its recovery setting. Ordinary settings reads exclude recovery bodies, and ordinary settings writes cannot bypass revision checks.

Snapshots capture committed text rather than an active IME preview. The saved baseline, selections and collapsed folds restore with the draft; its edits become one undoable recovery transaction. Paths, Unicode offsets, folds, scroll values, format versions and bounds are validated in shared code. Text encoding keeps control-heavy files within the same wire bounds as ordinary files. Limits are 64 tabs and 128 MiB of text/metadata, with each document using the editor's existing 32 MiB text limit. Failed writes preserve the preceding stored recovery.

The frontend backend facade now exposes typed recovery requests and collects coherent active/hidden snapshots with the original saved baselines. HTTP 409 is kept distinct from transport errors; recovery replies and save acknowledgements are validated. Old-session REST responses cannot expire a newly active session. Automatic loading and debounced saves are installed in the app. Saves are serialized per project; edits arriving during a write are saved after its acknowledgement.

Failures keep the last acknowledged revision and current drafts; Retry recovery resumes writes. A revision conflict pauses writes until Restore saved files or Keep this window is confirmed. Late loads cannot discard files opened or edited in flight. The disposable Spin/SQLite and Chrome check below verifies reload/new-window recovery. Recorded installed-PWA checks also cover native permission loss/regrant and retained drafts, plus interrupted file-journal rollback through the installed PWA. Other device checks remain open.

Recovery hydration primitives prepare all documents before publishing any state, restore ordered tabs and active or hidden buffers, and preserve unrelated workspace state. Guards reject a changed project, reset, pending read, document revision, selection, draft, or composition. Old media URLs are returned to the caller for revocation. Shared disk reconciliation preserves conflicting/missing drafts, detects an already completed write, and refreshes clean files.

Optional disk reads distinguish missing ancestors from permission/transport errors through the same Workspace primitive used by rewind. Recovered files are checked before host Save is enabled, and their baseline is checked again before a write. Missing/changed/unavailable host files preserve drafts and show feedback with Check disk again. Existing folder access controls restore local permissions. Review recovered file compares the current disk file with the draft using the shared inline diff.

Cancel retains both versions; Reload disk replaces the draft, and Save draft uses the normal save policy with a one-use approval for the reviewed disk and draft versions. Missing files can be recreated explicitly, including empty files. Changed editor/root/account state or disk content rejects the action. Additional native recovery and device checks remain on the roadmap.

Live recovery verification

After building the current app, run the disposable WASI/SQLite API check:

NO_COLOR=true spin build
python3 tools/check-editor-recovery.py

Browser and production-host checks also need a release execution host containing the compiled default bundle. From the repository root, build it once:

export WASI_SDK_PATH="$(python3 tools/install_wasi_sdk.py ~/.cache/openwebide/wasi-sdk)"
export WASI_SYSROOT="$WASI_SDK_PATH/share/wasi-sysroot"
export OPENWEBIDE_BUNDLED_ARTIFACTS="$PWD/target/language-checks-defaults.json"
cargo run -p openwebide-plugin-runtime --bin openwebide-bundle-plugins --release --locked -- bridge/bundled/plugins.json "$OPENWEBIDE_BUNDLED_ARTIFACTS"
cargo build -p openwebide-bridge --release --features bundled-defaults
CHROMEDRIVER=<compatible-driver> python3 tools/check-editor-recovery.py --browser
CHROMEDRIVER=<compatible-driver> python3 tools/check-language-host.py
python3 tools/check-language-client.py

The check creates its own account, database, host files and browser profile, then removes them. It preserves the existing development services and database. The API check covers both project modes, UTF-8/CRLF drafts and saved baselines, ordered selected/hidden tabs, invalid/root/stale revisions, actual Spin restarts and durable close-all tombstones. The browser check types into the built WASM editor, verifies real host analysis and the digest of the current source, observes its debounced database save, restarts Spin, reloads and opens a fresh window, and checks the selected tab and draft in both modes.

Local recovery is tested without a native folder handle; it does not establish real-device permission restoration. Set CHROME if ChromeDriver needs an explicit Chrome binary.

When running the full WASM UI test suite locally, match CI’s Chrome capabilities: include --window-size=1280,900 in goog:chromeOptions.args in webdriver.json. Desktop panel contracts require that viewport; individual narrow-layout tests set their own container sizes. CI gives the expanded frontend browser test binary 300 seconds via WASM_BINDGEN_TEST_TIMEOUT; this is a whole-suite budget, independent of each UI readiness assertion’s short deadline. Set the same environment variable locally when running the full suite on a slower host.

Retained parser/framing checks use a separate, temporary test-support bundle:

CHROMEDRIVER=<compatible-driver> python3 tools/check-editor-worker.py --fixture

This builds and serves isolated test assets from a disposable local HTTP server and verifies all grammar variants, startup readiness, incremental Unicode/CRLF, a UI event during preparation and oversized-source fallback. Its worker and PWA cache exist only in that fixture. Production artifacts must exclude them. This does not establish offline editing or real-device behavior.

See editor performance measurements for native/WASM text-storage comparisons and the remaining viewport/performance verification.

Browser-engine composition verification

After building the frontend, WASI backend and release host above, run:

CHROMEDRIVER=<compatible-driver> python3 tools/check-editor-input.py
CHROMEDRIVER=<compatible-driver> python3 tools/check-editor-input.py --windowed

The disposable release-app checks exercise Chromium's candidate updates, commit, cancel, and keyboard undo/redo through the actual Rust/WASM event handlers. The first command holds real host results until the first composition commits, so syntax is pending during input. The second requires bounded native surrounding text. Both run local and remote drafts with LF and CRLF, compare the full recovered source with the expected bytes, and verify cancellation adds no undo step. They also inspect the native input’s accessible name and keyboard description, then use trusted Ctrl+M, Tab and Shift+Tab to verify focus escapes in both directions without changing text or selection. Composition starts/updates, beforeinput/input and keyboard events are trusted; Chromium's CDP-generated composition-end events are untrusted. These engine checks run in CI but do not prove physical input devices, installed Chrome/Edge PWAs, clipboard permissions, touch selection or native local folder handles.

Full-editor admission and large text

The shared editor_limit policy checks 8 MiB of source, 100,000 display lines (LF/CRLF/standalone CR) and 1 MiB per line before interactive document metadata is allocated. Document::for_editor also enforces admission on transactions, including native input, composition previews and replicated multi-cursor edits. The frontend facade applies this contract to existing documents. General Document::new remains available for core storage experiments; its benchmarks above these limits do not demonstrate full-editor support.

Files outside these limits open as read-only, 16 KiB text pages. Adjacent pages preserve exact UTF-8 content, including a leading newline, and before/after review sources remain separately accessible. Paging never replaces the full workspace source or changes its saved state. Clean oversized recovery tabs retain their file reference and reopen through the shared Workspace adapter; legacy oversized drafts fail recovery admission without replacing current buffers or deleting persisted recovery data.

These admission limits bound source and metadata growth; they are not a claim that bounded cold wrapped paint or unique total editor memory has been validated. Production input/scroll and process-memory baselines are recorded in editor performance; they still reveal stalls at admitted file-size boundaries. Remaining work bounds cold and long-row wrapped rendering, reduces input/source costs, and repeats responsiveness and memory validation.

Indexed indentation guides

Guide queries borrow logical rows from the shared document index and cache an immutable table for its source version and indentation settings. Blank runs use the minimum indentation of their neighboring nonblank rows, including Unicode whitespace and LF/CRLF. The standalone core helper uses the same policy. Files above the structural byte limit share zero-guide tables across same-row-count edits and setting changes; row-count or limit changes invalidate them. Ordinary source edits recompute changed indexed rows and adjacent blank runs through their nearest nonblank neighbors. Unchanged guide values retain the original table; changed values copy retained columns around the replacement, without rescanning unrelated source rows. Setting changes still rebuild the full table. Cached tables remain immutable across document clones and undo.

Cooperative plain-source paint

Host analysis and fallback paint share the facade's retained source snapshot for the current file, project, account, reload and review generation. Repeated requests and tab-width changes share that allocation, including while analysis is pending. New snapshots copy directly from borrowed editor content, without an intermediate full String. Source or ownership changes replace the snapshot; reset and requests without an open file clear it. Facade-owned scopes use the shared source revision and retained immutable allocation to validate current source without scanning bytes. Content replacement invalidates older scopes even when the new bytes match; the new request may reuse the same source allocation after checking those bytes. External snapshots still require complete-byte validation, and host transport still serializes the requested source.

When a host is unavailable or finishes without usable syntax paint, the editor facade prepares fallback rows through a resumable Rust plain-source job. The same lossless row preparation serves synchronous core callers and cooperative browser jobs. Each batch admits at most 128 rows and 64 KiB of source, allowing one oversized row. Rows receive one plain token rather than per-character code guesses. A first bounded batch can finish a small file without a pending frame. Larger jobs yield browser tasks between batches and request a frame after 4 ms of preparation or 64 batches, whichever comes first. Missing/nonfinite/backward clocks retain the conservative eight-batch frame schedule. This bounds rendering deferral while allowing cheap retained rows to finish without nearly a hundred frame waits. No partial token table is published, and pending paint borrows projected source bodies or retains an already scoped styled frame. Full-row probes wait for cooperative fallback tokens instead of measuring a neutral table that will be discarded. Pending background requests retain their borrowed source preview. Both decisions use the same editor facade, and native input stays visible during cold preparation.

Rules resolution is memoized above workspace adapters, including detected/default rules when configuration cannot be read. Repeated ownership checks reuse that result; source, file/project, preferences, loaded rules and indentation overrides invalidate it through their existing reactive dependencies.

Initial geometry installs the shared source document index before syntax completes. After native text is installed, bounded neutral unwrapped frames can publish without an animation callback, admitting at most 128 rows and 64 KiB of source. Identical source/font/layout frames revalidate without reinstalling DOM paint. Styled, wrapped and oversized cold paint retain their preparation path; touch keeps the complete native surface. Replacing a large windowed document with complete short native text releases the old binding so its retained scroll extents cannot survive. Browser contracts hold both frame callbacks and lexical jobs while checking native binding and source-column/line-end clicks in both modes.

The job owns immutable source and reuses a completed syntax source allocation when available. CRLF normalization happens per row, preserving standalone CR and avoiding a normalized full-file copy. Source, read, pending-edit, account, path and tab-width changes cancel obsolete work; completed tokens are shared by subsequent paint consumers. Completed plain-source snapshots retain raw row boundaries. Identical source with matching language and newline normalization completes immediately and shares both row and token tables. Shared source validates by allocation; external equal text validates bytes. A changed source computes one UTF-8 replacement span. Whole prefix/suffix rows reuse indexed raw boundaries without newline scans or repeated byte comparisons; terminal rows must still terminate the new source. Intersecting rows scan their boundaries and validate complete raw text against original/shifted offsets. Comment delimiters do not affect fallback colors or following rows. Row insertions/deletions and disjoint edits cannot reuse mismatching raw text. Language and newline-normalization changes invalidate reuse. The shared plain-row preparation uses the same job with per-row cancellation. Published rows use immutable shared token slices, so plain-row reuse retains existing token strings without copying their text or token arrays. Parser paint streams the ordered protected/embedded/semantic span boundaries without building a complete boundary set or vector. Duplicate edges merge before paint. Component analysis and validated host results use the same row representation; the painter reads those rows without materializing a second token table. Row metadata and handle tables still visit changed source, and source-change comparison still scans unchanged prefix/suffix text. Shared change comparison uses byte chunks and adjusts only differing edges to UTF-8 boundaries, retaining minimal character spans without decoding complete unchanged text. The host toolkit and explicit test-support builds retain parser APIs. Production browser fallback uses the plain-source job and never runs those engines.

This makes terminal plain-row work cooperative; it does not make full-source snapshot ownership, parsing, geometry or long-row initial shaping incremental. Those remaining limits are tracked in the roadmap and performance guide.

Pointer gestures flush pending source paint when analysis has temporarily marked hit-testing unavailable. The current input target, source scope and glyph geometry are revalidated before translating to source coordinates; bounded native windows never supply whole-file pointer offsets.

Gutter digits query the active document’s source-row index, including hidden fold rows and a trailing empty row; folds do not shrink source-number width. Native restoration compares the input against the projection’s already-normalized value without creating another normalized source copy.

Retained parser protocol (test support only)

The following describes the historical version-6 browser-worker transport, retained by check-editor-worker.py --fixture for framing and parser regression coverage. It does not describe the production host language protocol. That protocol uses the versioned SDK's Analyze/Close requests and source-bound analysis results; no worker bootstrap, row-reference framing or structural patch receiver is shipped in the browser bundle.

Worker protocol v6 replies reference unchanged token rows from the last published base ticket. Consecutive references transfer as runs, so one edit does not serialize a reference record for every unchanged row. The receiver checks the ticket, count, old row range, exact new row coverage and reconstructed token budget before sharing existing allocations. Account, document, read and tab-width changes clear the frontend base; a full-source request without a matching worker base produces a standalone result. Malformed references are transport failures and retain the existing safe fallback. Replies also publish a UTF-8 replacement span when it is smaller than the full source. The receiver validates its range, unchanged prefix and suffix, inserted text and resulting length against the exact requested source before accepting it. Malformed spans are rejected. Full-source requests without a matching worker base produce standalone replies. Requests use the same span contract. If the worker no longer has the advertised base, it asks for a full snapshot; the shared publication facade retries once after rechecking source, account, read and ticket ownership. A second resync response stops the transport and uses the shared fallback. Invalid ranges remain transport failures; reconstructed byte and row limits apply before analysis. Structural publication can transfer changed record spans, while reconstruction and row tables still visit all rows. Validated replies retain the facade's immutable source snapshot, and warm syntax queries use it without cloning the full buffer; source/read/account guards still run around callbacks. Initial preparation and changed rows still allocate token text.

Worker structural publication compares retained record lists and sends their changed spans when that avoids a complete list copy. Source byte coordinates remain distinct from record indices. A patch requires the acknowledged ticket and matching language; small lists and language changes retain standalone data. Reconstruction checks every list range and the aggregate expanded record budget before allocating, then applies the existing source/coordinate/bracket validation. Structural extraction and receiver reconstruction/validation still visit the full lists.