Skip to content

Add examples/web-chat: Ed running in the browser - #62

Merged
setoelkahfi merged 4 commits into
feature/ed-agent-wasm-seamsfrom
feature/web-chat-example
Nov 18, 2026
Merged

setoelkahfi merged 4 commits into
feature/ed-agent-wasm-seamsfrom
feature/web-chat-example

Conversation

@setoelkahfi

@setoelkahfi setoelkahfi commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #57. Adds a small example that runs Ed entirely in a browser tab: it downloads Qwen 2.5 0.5B (about 380 MB), loads it, and chats with it. Nothing leaves the device.

A module worker owns one Ed compiled to wasm32-unknown-unknown, and the page talks to it through postMessage, so a forward pass never blocks the UI. The model is stored once in Cache Storage and a reload loads it without downloading again. There is no bundler or npm step: build.sh runs wasm-pack and any static server can host www/.

The crate is excluded from the workspace and has its own build, so native CI is unaffected.

Not ready to merge

The example needs web_store and the browser engine from onde, which is in ondeinference/onde#50 and not yet released (1.4.0 is the latest on crates.io). Until a release has it:

  • the example does not build from crates.io, so CI does not build it and its Cargo.lock is not committed
  • the onde dependency in examples/web-chat/Cargo.toml still says 1.4.0

Once a release with the engine is published:

  • bump onde in the example, and in the workspace if Add wasm-friendly seams to ed-agent #57's requirement should move
  • run cargo update in examples/web-chat and commit the lockfile
  • add cargo clippy --locked --target wasm32-unknown-unknown --manifest-path examples/web-chat/Cargo.toml -- -D warnings to the check-wasm32 job

What I ran

I built against a local checkout of onde (--config 'patch.crates-io.onde.path=...') and drove the page with Playwright:

  • clippy on wasm32 passes with -D warnings
  • the download shows byte progress, then the chat view appears
  • two turns stream, and the second answers from the first ("What is my name?" returns the name given earlier)
  • Stop, New conversation and Remove model work; after Stop the model reloads and chat continues
  • after a page reload the card says "Load the model" and nothing is downloaded again

Speed is 1.2 to 2.5 tokens/s on an Apple Silicon Mac (CPU, one thread, SIMD). One of my download attempts died at 46% with a Cache.put() network error and the retry finished. Downloads are not resumable, which is down to onde's web_store, not this example.

A small page that loads Qwen 2.5 0.5B and chats with it entirely on the
device. A module worker owns one Ed instance compiled to
wasm32-unknown-unknown, and the page talks to it through postMessage. The
model downloads once into Cache Storage; a reload loads it without
downloading again. Stop terminates the worker and starts a new one, so it
also clears the conversation.

There is no bundler or npm step: build.sh runs wasm-pack and any static
server can host www/.

The crate is excluded from the workspace and builds only for wasm32. It
needs onde 1.5.0 for web_store, which is not published yet, so CI does not
build it and its Cargo.lock is not committed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si>
Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
@setoelkahfi
setoelkahfi added this pull request to stack #63 November 16, 2026 12:25
@setoelkahfi setoelkahfi changed the title examples: add web-chat, Ed running in the browser Add examples/web-chat: Ed running in the browser Nov 16, 2026
@setoelkahfi setoelkahfi self-assigned this Nov 16, 2026
@setoelkahfi
setoelkahfi marked this pull request as ready for review November 16, 2026 12:35

@sigit-code-review sigit-code-review Bot 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.

Adds examples/web-chat, a standalone crate (excluded from the workspace) that runs Ed in a browser via a wasm32 Web Worker. The worker owns a WebChat wasm-bindgen wrapper around Ed; the page (main.js) drives it with postMessage. The model (Qwen 2.5 0.5B) is downloaded once into Cache Storage via onde's web_store and reused on reload. build.sh runs wasm-pack with +simd128; no bundler or npm. CI path filters now include examples/**. The PR is explicitly not-ready-to-merge until onde publishes a release with web_store (the Cargo.toml still pins 1.4.0, README says 1.5.0).

Key things to look at: the RUSTFLAGS fallback in build.sh (line 11) silently drops any caller-provided flags; the onde version mismatch between Cargo.toml and README; and the worker's message handler, which drops messages while chat is null (boot in progress) without error feedback.


Automated review by siGit Code Review · commit bfd820c · see the review dashboard

Comment thread examples/web-chat/build.sh Resolved
Comment thread examples/web-chat/Cargo.toml Resolved
Comment thread examples/web-chat/www/worker.js Resolved
Comment thread examples/web-chat/www/main.js Resolved
Comment thread examples/web-chat/src/lib.rs Resolved
…eplies

build.sh now appends +simd128 to an exported RUSTFLAGS instead of dropping
it. The worker answers a message that arrives before Ed has started with an
error instead of ignoring it. A reply that fails after some tokens streamed
keeps its text and gets the error appended. The onde comment in Cargo.toml
now says the dependency waits on ondeinference/onde#50 rather than on a
version number.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si>
Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>

@sigit-code-review sigit-code-review Bot 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.

The follow-up diff closes the open review threads: build.sh now appends +simd128 even when RUSTFLAGS is exported, the worker returns an error for messages that arrive before chat is ready, and main.js appends error text after any already-streamed tokens. The Cargo.toml comment now matches the pinned 1.4.0 dependency and explains the unreleased onde requirement. No new issues found.


Automated review by siGit Code Review · commit c196d65 · changes since bfd820c · see the review dashboard

Add deploy.sh and the smbCloud config that ship www/ as a static
artifact, plus share metadata and an Onde byline on the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: siGit Code v1.6.6-acp <noreply@sigit.si>

@sigit-code-review sigit-code-review Bot 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.

The previous review points were addressed in c196d65. This set adds the smbCloud deploy config, a deploy.sh that guards the app id, stages the built page plus a generated version.txt, publishes, and polls for liveness, plus SEO meta tags and a footer byline. The deploy flow looks sound; only a small timeout-message mismatch stands out.


Automated review by siGit Code Review · commit a13a5a3 · changes since c196d65 · see the review dashboard

fi
sleep 2
done
echo "$URL did not report $version within 30s (last saw: ${live:-nothing})" >&2

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit — The final message says the script gave up after 30s, but the loop is 15 attempts with up to 5s of curl timeout plus a 2s sleep each, so it can actually wait about 105s before failing.

An SVG mark (white e on the brand green) with a PNG apple-touch fallback, linked from the page head and shipped by deploy.sh.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: siGit Code v1.6.6-acp <noreply@sigit.si>

@sigit-code-review sigit-code-review Bot 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.

This delta since the last review only adds a favicon: favicon.svg and apple-touch-icon.png are new, index.html links both, and deploy.sh copies them into the staging directory so the deployed site stays in sync. The earlier findings from c196d65 (RUSTFLAGS appending, the onde version comment, the worker's early-message error reply, and the error-text annotation in main.js) are addressed and I have nothing further on them. The unanswered deploy.sh timing nit from last round is untouched by this delta and still stands as posted. No new issues in the icon changes.


Automated review by siGit Code Review · commit 260ce0e · changes since a13a5a3 · see the review dashboard

@setoelkahfi
setoelkahfi merged commit 3471bd6 into main Nov 18, 2026
5 checks passed
@setoelkahfi
setoelkahfi deleted the feature/web-chat-example branch November 18, 2026 09:42
This was referenced Nov 19, 2026
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.

4 participants