Files
endorphin-tessera-gui/src
2026-10-23 00:42:48 +08:00
..

Tessera source

Module Responsibility
main.rs Native window event loop, namespace state and API startup
api.rs Code CRUD, live Console/reset and compatibility evaluation endpoints, worker-owned session, request observation, coalesced native viewport/background-task updates, epoch checks, stale source/destination tab-drop rejection and diagnostics
activity.rs Bounded in-memory HTTP exchanges with marked previews and allowlisted request headers
endor_host.rs Aster compilation, fresh PUT candidates retained after successful publication, shared Console/program VM, asynchronous completion/fault boundaries, bounded execution, compiled source/call-graph effect query and rebinding coverage, root cleanup and AST developer tree for function/class/member assignment nodes
endor_script.rs Batch complete inputs for Aster's Interactive parser/compiler, retain Module entry, and rebase Aster spans to the original snapshot
ui_bridge.rs Inheritable native nominal constructors with source fields, shared type method tables and bound receiver dispatch, configured unified Function classification and source/field/override checks with deferred typed public/native constructor signatures and split option/field preflight plus shared native arity intervals plus resolved types/unions/effects on methods, tab registry, stable-slot insertion, source-dispatched tab reorder/drop and callback registration checks, Page lifecycle/navigation, Event returns/effect bounds, intrinsic handler recognition and immutable frame extraction
binding.rs Target-owned managed property bindings, weak Subscription tokens, zero-argument callback preflight, read-only compute and borrowed dependency/output caches
block.rs Aster-managed Block/Cell/data graph, stable child slots, content-owned field storage, shared assignment, cycle validation and explicit text bindings
snapshot.rs Property and visual-method identity dependencies across shared field-storage paths, typed method attribute validity and protocol function payload-version dependencies, reverse parent links and cached immutable visual derivation
mount.rs Typed per-occurrence methods and nominal Bounds results, managed contexts, weak reverse links, ordered mount/unmount hooks, geometry and focus queries
events.rs Bounded native input transport with kind-specific tab-drop/desktop-position metadata to the owning VM
event_dispatch.rs Typed Event factory and managed Event/Subscription methods, weak Subscription tokens, Block-owned connections and occurrence-specific capture/target/bubble through a budgeted VM driver
protocols.rs Register typed Visual/EventTarget/Children (including insert)/Presentable managed trait requirements, using canonical signatures and explicit native type declarations
presentation.rs Per-window layout, Mount/focus/tab state and read dependencies; VM changes fan out before any view consumes work
tasks.rs Typed Task/ui.after methods, managed owner scopes and callbacks, weak timer index, request-key replacement, lifecycle cancellation and budgeted worker delivery
tabs.rs Immutable tab chrome, shared draw/hit geometry, overflow navigation, drag gaps/anchors/insertion markers and opaque published Page identities
window.rs Typed native Window queries/effects, construction/close, context ownership, ordered Page roots, read-only guards, Page reordering, physical desktop placement and coalesced GUI projections
vm_sequence.rs Shared validated call-sequence builder and EXTENDED_ARG-aware same-frame repetition for layout, event and lifecycle work
source_layout.rs Read-only source layout, repeated constraint/geometry solving with cycle detection, per-Mount measurement caches with subcall dependencies and actual scroll-viewport cross-axis constraints, viewport constraints, typed/slot validation, concrete intrinsic recognition and occurrence geometry
source_hit.rs Read-only source/native pointer target selectors, reverse paint order, strict Bool results and matching press/release targets
source_paint.rs Read-only source paint dispatch with concrete intrinsic recognition, shared VM budget, paired text-wrap bounds and checked command conversion and versioned object dependencies
native_visual.rs Managed native visual protocol queries with resolved type/read-only signatures, occurrence validation, concrete implementation/operation identity, arranged-viewport child constraints, value conversion and bounded results
object_list.rs Typed factory envelopes, read-only indexed access and traced results shared by Mount queries and visual protocol results
layout.rs Shared native geometry/paint functions, iterative measurement/arrangement, stable occurrence IDs, measurement cache, solve-pass counters, geometry budgets and width-sensitive native text measurement
document.rs Published source/AST/UI snapshot, revisions, invalidation, frame validation, single-line fault banner (full cause retained in Frame), validated optional text-wrap bounds and display commands
app.rs Window events, logical viewport publication, redraw, native multi-window tab dragging and system widget pointer/keyboard/IME routing
clipboard.rs UTF-8 macOS clipboard adapter independent of Finder locale, with strict decoding and surfaced errors
system_ui/ Host-only management widget library: stable IDs, interaction, theme and reusable control drawing
scroll.rs Per-Mount offsets, nested scrollIntoView, shared geometry/clip projection and wheel ancestor selection
scene.rs Page, tab-drop marker and developer-tools display-list composition
developer_tools.rs Unified Console prompt/output stream, caret/IME mapping, full Sources, Network inspector, theme, scrolling, overlay splitters and focus
sources.rs Disconnected cloud workspace and provider boundary for listing/opening complete source files
display_list.rs Rendering primitives, bounded wrapped text and color representation
geometry.rs Native points and rectangles
software_renderer.rs Software rasterization, per-text bounds and nested rectangular clipping for independently scrolling panes
text.rs Shared system font discovery, shaping, real measurements, antialiased glyphs and bounded caches keyed by wrap width
README.md Module map

Aster is an independent source submodule pinned to the published managed type/native-call implementation. Language parsing, AST definitions, compilation, bytecode and VM execution come from its libraries. Tessera implements only host UI behavior and layout. No CLI, HTTP server or Docker process is needed to execute Endor in the application.

A complete-PUT candidate owns the desktop and UI service roots, with dynamic Block allocation through scoped NativeContext. Block -> Cell -> data and all child/history/forwarding references are managed VM edges. Native functions declare their captured owner edges. The bridge holds only weak diagnostic references to allocated Blocks; the tab registry owns open Pages. Closing a tab releases that edge, without destroying a still-referenced Page. Console retains the actual VM; a successful complete PUT also retains its candidate as the active program, accessible from Console and native input. Failed PUT preserves the previous heap. Cleanup releases globals/service roots, collects cycles and requires an empty VM. Window frames contain only immutable native data.

Tests in api.rs execute real HTTP CRUD, persistent Console/reset/PUT isolation and a controlled queued-PUT/DELETE race without opening a window. Tests in endor_host.rs cover lifecycle, direct script and module entry, page methods, stable-slot insertion and tab drop/override/stale-target behavior, multiline inputs, original source ranges, malformed input, owner/task cancellation, hidden-object delivery, stale request and callback failure, entry checks, source function/declared-field annotation checks, constructor side-effect prevention, native callback signature/pre-registration validation, shared field forwarding/function identity and REPL class redefinition, budgets, failure preservation, live object identity, explicit rendering, compile-before-execute behavior and stale-result invalidation. They run only in remote CI. Font tests in text.rs and software_renderer.rs cover real advances, multiline height, fractional scaling, CJK fallback, grapheme-safe fitting, antialiasing and transparency. A process-wide mutex keeps font discovery, shaping and glyph caches shared between the worker's layout and window redraw. The 256-string/512-KiB source cache and 4096-glyph/32-MiB image cache are discarded when their budgets are exceeded. See the project guide for public behavior.

The expression endpoint deliberately uses Aster's Expression entry in a fresh VM; it has no host UI, no history replay and no published document. API observation notifies the window for accepted and completed requests, including failures. The worker still owns source compilation and snapshot publication. Console sends real loopback HTTP requests on a separate client thread and reports transport failures through the native event loop. CloudSourceProvider is an optional host-side adapter, not a cloud service. A future network adapter should deliver cached/asynchronous results to the workspace rather than block the native event loop during I/O.

The System UI library owns management control appearance and interaction. It imports no Endor runtime or guest UI bridge; developer tools supply typed actions and keep all execution/source behavior outside the widget layer.

Console sessions use endor_host::ReplSession on the same worker thread. Real VM globals, live Blocks and _ survive between inputs. Parse/compile precede execution; only a successful input commits a pending mount or publishes changes to an existing mount. Runtime-failed input can retain earlier completed bindings, but cannot publish its pending render. Session budgets cover cumulative source/AST and live Block counts. page.unmount releases current content; unreachable object cycles are reclaimed between inputs. Explicit reset drops the VM. Successful PUT replaces it with the fresh program; failed PUT restores the displayed program’s event epoch. Code DELETE invalidates the context. Source snapshots carry annotated AST ranges for the actual Console transcript; source history is never rerun to reconstruct memory. The Aster pin includes independent Assignment syntax and generic opt-in assign_from support. Live reference tests cover alias updates, nested mounts, cycle rejection, detached branch release and unmount/remount.

Stopped runtimes have a separate host-only secondary-window teardown path. It detaches Mounts and releases window/Page roots without executing source lifecycle callbacks, and does not resume the failed VM. Preserved old-generation pictures can be closed without borrowing a new Console VM's same-number resource. Secondary viewport inputs are filtered by their published runtime generation. Native window/surface failures are returned to the host diagnostics rather than panicking the event loop; main window initialization errors propagate to process exit. The stopped-window and cross-generation regression sources are compiled, not locally executed.

Native visual scalar parameters live in the Block's managed property storage. Snapshot extraction validates and reads those fields, and records exact property invalidation keys. Payload kind values remain constructor defaults; drawing uses the property projection. Binding refresh traverses the weak visual registry and deduplicates forwarded content, including hidden objects. It records object-level read versions and borrowed output values for equality without adding GC roots; cache updates do not mutate the connection's business version. Target content traces the compute function. Subscription tokens are weak and also support bindings. All binding work settles before published frames; compute failure stops the VM.

The host registers Trait definitions through Aster's checked nominal capability API. Source subclasses validate inherited method arity before class publication. Presentable dispatch uses a generated validated bytecode continuation inside the current call budget, passes the current managed Window, and validates a real Block result before opening it. Native base visual methods and runtime result checks remain the rendering boundary. Matching present names without an explicit implementation keep the summary fallback and do not execute guest methods.

ScrollBlock keeps viewport dimensions in the managed Block properties and keeps scroll offsets on Mounts. Layout measures content without a finite viewport bound; a post-layout projection clamps offsets, translates descendants and intersects ancestor clips before committing Mount geometry. It rebuilds native commands and per-command clips; source painting preserves the same clip table. Input, focus outlines and public hit queries consume this projection. Wheel transport carries finite signed deltas, validates the frame/window/session, and invokes the actual Mount.scrollBy method without changing guest focus. Mount requests mark a per-window projection refresh; snapshots/caches never own business objects.

Tab drops validate source and destination window/session/layout plus the actual VM Page order before callbacks. The bridge invokes managed Page methods, respecting source overrides that decline or redirect a window move. Reordering within a window retains Mounts; moving windows retains Page identity and replaces Mounts. Native drag feedback is host state, with no additional managed roots. Desktop placement is an asynchronous physical outer-origin request, protected by the existing session/commit boundary. Regression sources cover the HTTP event allowlist, stale frame reuse, stable insertion, source overrides and signed positions; these were compiled, not locally executed.

NativeCallable implementations publish positional metadata, including internal layout/paint/hit/event continuations. The VM validates it before entering Rust. Event delivery uses the same source/native/bound arity query; binding and Task registration reject incompatible or unknown metadata before changing ownership. Native parameter/return types and effects remain checked by existing host boundaries rather than this count-only metadata.

Native TextBlock measurement and painting now share width-sensitive shaping. Column/Button cross-axis constraints feed both the native fast path and source base calls; direct base measurement also uses its supplied viewport. RenderCommand text has optional wrap_bounds, converted to a clipped WrappedText primitive. Source PaintCommand uses paired wrapWidth/wrapHeight and legacy text remains unwrapped when both are absent. Source-arranged dimensions now participate in repeated constraint solving; general flex allocation, resumable work and axis-specific ScrollBlock wrapping remain future work.

Layout convergence uses exact finite snapshots of constraints/sizes/bounds and source-selected limits. The same immutable driver loops within one shared VM budget, clears all provisional measurement geometry between passes and rejects nonconsecutive repeated states. Aster ReadAccess distinguishes annotation validation from normal reads; the bridge skips only validation-only Mount reads after independently validating the live Mount/owner context. Actual Mount reads remain volatile; all other recorded dependencies are retained.

ScrollBlock.axis is stored in its managed properties and projected into the visual snapshot. Axis-aware child constraints use constructor/clamped size for initial measurement and actual occurrence bounds after arrangement. Scroll projection clamps disabled offsets/limits; the same geometry feeds paint and input.

Container mainAlign projects from managed properties into UiNode and its shallow equality. Native arrangement receives the actual allocated Size, computes positive remaining main-axis space and keeps child sizes unchanged.

Block.flex is a nonnegative managed weight, default 0. In native containers, fixed children retain measured main-axis sizes; positive weights share the remaining allocated space after padding/gaps with zero basis. This does not request extra parent size. Actual allocated child bounds feed back into measurement before publication. Source arrangement overrides remain authoritative. The additional flexBasis, flexMin, flexMax and flexShrink attributes control bounded allocation and opt-in shrinking along the parent main axis; see the policy below.

Trees with positive flex weights use the settling driver even when all layout methods are native. This remeasures wrapping and ancestor geometry before publishing. Fast-path eligibility checks actual intrinsic implementations, rather than comparing against a mutable Block method table.

Flex main-axis policy: flexBasis is "auto" by default (zero basis when flex > 0, otherwise the first measured size of this occurrence in the current solve); a number supplies an explicit basis. flexMin defaults to 0, flexMax to 1000000, and flexShrink to 0. All numbers are finite/nonnegative and at most 1000000; flexMin must not exceed flexMax. The parent clamps bases to min/max, distributes positive space by flex, and redistributes space left after a maximum is reached. Deficits shrink by flexShrink times the original basis, freezing at minima. A fixed child can opt into shrink without growth. Unresolvable minimum overflow is preserved, and remaining positive space follows mainAlign. The policy applies to width in a Row and height in Column-like containers; these are not independent width/height bounds. Source arrange overrides remain authoritative. Preferred sizes are derived per occurrence and reset for each new solve, never shared through Block state. See examples/flex-constraints.endor. Layout continuation remains unfinished.