Skip to content

feat(website/sandbox): add Run panel#142

Open
rvolosatovs wants to merge 1 commit into
LFDT-Nightstream:mainfrom
rvolosatovs:feat/sandbox-run
Open

feat(website/sandbox): add Run panel#142
rvolosatovs wants to merge 1 commit into
LFDT-Nightstream:mainfrom
rvolosatovs:feat/sandbox-run

Conversation

@rvolosatovs

@rvolosatovs rvolosatovs commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Add a basic "Run" panel to the sandbox, which allows "deploying" the contract and then "creating" multiple instances of UTXOs out of them for calling individual exports. This is just the first sketch, which will likely change significantly going forward.

  • Everything is added to the existing Wasm module for simplicity, but splitting these would probably make sense as a follow-up
  • This PR is almost entirely generated by an LLM, mostly verified by using the sandbox UI. I have lightly reviewed the Rust code and I did not review JS/frontend.

Recording of the UI available here: https://www.youtube.com/watch?v=CcCSNLWJmnY

Blocked on #150

@rvolosatovs rvolosatovs force-pushed the feat/sandbox-run branch 4 times, most recently from af65e43 to ec766af Compare June 8, 2026 12:46
@rvolosatovs rvolosatovs marked this pull request as ready for review June 8, 2026 13:28
//! Wasmtime "custom platform" implementation for a browser-like wasm32 host.
//!
//! Wasmtime doesn't recognize wasm32 as a supported OS, so with the
//! `custom-virtual-memory` feature it calls out to a small C-ABI for its

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, I did miss this feature before somehow

@rvolosatovs

Copy link
Copy Markdown
Contributor Author

I'll rework this to integrate #150 and the updated UI

@rvolosatovs rvolosatovs marked this pull request as draft June 17, 2026 12:01
@rvolosatovs rvolosatovs force-pushed the feat/sandbox-run branch 2 times, most recently from 4a82b2c to d49410d Compare June 17, 2026 14:49
Comment thread starstream-sandbox-web/src/lib.rs Outdated
Comment thread starstream-sandbox-web/src/lib.rs Outdated
Comment thread starstream-sandbox-web/src/lib.rs Outdated
Comment thread starstream-sandbox-web/src/lib.rs Outdated
@rvolosatovs rvolosatovs force-pushed the feat/sandbox-run branch 2 times, most recently from c5f347f to 8497d2b Compare June 17, 2026 15:13
@rvolosatovs rvolosatovs requested a review from Copilot June 17, 2026 15:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an initial “Run” panel to the website sandbox by introducing a long-lived run worker and extending the starstream-sandbox-web Wasm module to host a minimal contract runtime (deploy → construct UTXOs → call methods, plus storage + events).

Changes:

  • Add website/src/run.worker.ts and a new Run tab UI in website/src/pages/sandbox.tsx for deploy/construct/call/storage/events.
  • Extend starstream-sandbox-web with a Wasmtime-on-wasm32 “custom platform” + runtime entrypoints (deploy, construct, call, etc.).
  • Introduce starstream-runtime-next and a test-contracts helper crate + examples/score.star + runtime tests.

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
website/src/sandbox.worker.ts Add no-op import hooks required by the expanded Wasm ABI (run tab handled elsewhere).
website/src/run.worker.ts New WebWorker that keeps one Wasm instance alive to persist runtime state across messages.
website/src/pages/sandbox.tsx New Run tab UI: deploy component, construct UTXOs, call methods, view storage/events/logs.
website/src/editor.tsx Update default example program to the “score” contract used by the Run panel/tests.
website/src/css/custom.css Styling for the Run tab (deploy selector, cards, logs, forms).
test-contracts/src/lib.rs Expose compiled example contract bytes via include_bytes!.
test-contracts/Cargo.toml New crate manifest for building/embedding example contracts.
test-contracts/build.rs Build script compiling examples/*.star to core Wasm into OUT_DIR.
starstream-to-wasm/Cargo.toml Align wasmtime dev-dep usage with workspace configuration.
starstream-sandbox-web/src/platform.rs Add wasm32-friendly Wasmtime “custom virtual memory” platform ABI implementation.
starstream-sandbox-web/src/lib.rs Add runtime entrypoints + JSON/Val plumbing + deploy/construct/call/storage/events.
starstream-sandbox-web/Cargo.toml Add runtime + wasmtime/cranelift deps required for in-browser execution.
starstream-sandbox-web/build.rs Add wasm stack-size linker arg for deploy-time compilation recursion.
starstream-runtime-next/tests/score.rs New integration tests validating UTXO construction, calls, storage and events.
starstream-runtime-next/src/lib.rs New runtime crate wrapping Wasmtime component model for UTXO construction/calls/storage.
starstream-runtime-next/Cargo.toml New crate manifest (features + deps) for runtime-next.
starstream-cli/Cargo.toml Use workspace serde_json dependency.
rust-toolchain.toml Bump pinned Rust toolchain version.
interleaving/starstream-runtime/Cargo.toml Switch wasmtime dep to workspace version.
interleaving/starstream-component-runtime/Cargo.toml Switch wasmtime dep to workspace version.
examples/score.star Add score example contract source used by sandbox/tests.
Cargo.toml Add new workspace members and workspace deps.
Cargo.lock Lockfile updates for new crates/deps (including Wasmtime 46 line for sandbox/runtime-next).
.cargo/config.toml Add wasm32 linker flag for importing undefined symbols on newer toolchains.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread website/src/pages/sandbox.tsx
Comment thread website/src/pages/sandbox.tsx
Comment thread starstream-sandbox-web/src/lib.rs Outdated
Comment thread starstream-runtime-next/tests/score.rs
Comment thread starstream-runtime-next/tests/score.rs Outdated
Comment thread starstream-sandbox-web/build.rs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.


/// Flush and report the ABI events buffered during an operation.
fn flush_events(events: &Rc<RefCell<Vec<Value>>>) {
let drained: Vec<Value> = std::mem::take(&mut events.borrow_mut());
Comment thread website/src/run.worker.ts
Comment on lines +271 to +274
self.onmessage = async function ({ data }: { data: RunWorkerRequest }) {
request_id = data.request_id;
const wasm = await getWasmInstance();
try {
rvolosatovs added a commit that referenced this pull request Jun 23, 2026
Migrate the runtime crate from
https://github.com/rvolosatovs/starstream-run/

This requires a git rev of Wasmtime and will continue to do so until
Wasmtime 47 release, i.e. ~1 month, so for now introduce a custom
Wasmtime version (and related tooling) only for this crate

This will be used by the website sandbox (#142 ) as well as the
mock-ledger.

This PR also adds an `examples` dir with the score example I've been
using for testing. That example is now compiled to Wasm and available
via `test-contracts` crate.

~Blocked on #149~

---------

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Add a Run tab to the website sandbox: a long-lived run worker drives the
compiled contract through deploy → construct UTXOs → call methods, with
storage and event views.

Built on `starstream-runtime-next` (LFDT-Nightstream#150); the sandbox is pinned to the
exact Wasmtime rev that crate uses so their `Utxo`/`bindings`/`Val` types
unify into one `wasmtime` instance.

Assisted-by: anthropic:claude-opus-4-8
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
@rvolosatovs rvolosatovs marked this pull request as ready for review June 23, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants