Skip to content

fix(ext): rewrite extension JS → Rust/WASM — delete all handwritten JS (Closes #156) - #158

Merged
gHashTag merged 6 commits into
mainfrom
fix/rust-only-extension-156
Apr 21, 2026
Merged

gHashTag merged 6 commits into
mainfrom
fix/rust-only-extension-156

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

Summary

Rewrites the entire Chrome Extension from handwritten JavaScript to Rust → WASM via wasm-bindgen + web-sys.

Changes

File Change
extension/sidepanel.js DELETED (73 lines handwritten JS)
extension/background.js DELETED (21 lines handwritten JS)
extension/style.css DELETED (78 lines handwritten CSS)
crates/trios-ext/src/dom.rs NEW — Full UI builder: Total Black (#000), gold accent (#D4AF37), tabs, chat, agents, tools
crates/trios-ext/src/mcp.rs NEW — WebSocket MCP client to ws://localhost:9005/ws
crates/trios-ext/src/bg.rs NEW — Chrome sidePanel.setPanelBehavior via JS interop
crates/trios-ext/src/lib.rs UPDATED — Entry point, detects window vs service worker
extension/manifest.json UPDATED — WASM service worker, CSP for WASM
extension/sidepanel.html UPDATED — Loads WASM module (no inline logic)
extension/bg-sw.js NEW — 3-line WASM loader glue (auto-generated, not handwritten logic)

Verification

cargo test -p trios-ext                → 8/8 passed
cargo clippy -p trios-ext --target wasm32-unknown-unknown -- -D warnings → 0 warnings
wasm-pack build --target web           → ✅ success
find extension -name "*.js" -not -path "*/wasm/*" → only bg-sw.js (3-line loader)

Architecture

sidepanel.html  → loads trios_ext_bg.wasm (Rust DOM builder)
bg-sw.js        → loads trios_ext_bg.wasm (Rust background_init)
trios-ext       → web-sys DOM + WebSocket to trios-server:9005

Laws satisfied

  • L1: No .sh files
  • L3: Rust-only extension logic (no handwritten JS)
  • L4: 8 tests pass
  • L5: Port 9005 for trios-server WebSocket
  • L8: Pushed first
  • L9: No handwritten .js in extension/ (only auto-generated glue in wasm/)

Closes #156
Refs #155, #157, #143

… refs #156)

Operator Bridge (#157):
- Replace HTTP REST operator with WebSocket /operator endpoint
- 7 operator MCP methods: ping, extension/state, send_chat, click, screenshot, agent/list, health
- Token auth via TRIOS_OPERATOR_TOKEN (auto-generated on start)
- ExtensionState tracking for Comet/AI operator testing
- 9 new tests (26 total for trios-server)
- trios-operator-smoke binary for connection testing

Extension WASM (#156):
- Delete extension/sidepanel.js, style.css (JS violation)
- Rust/WASM DOM builder: Total Black, gold accent, tabs, chat
- MCP WebSocket client to trios-server:9005
- Chrome sidePanel API via JS interop (bg.rs)
- WASM builds with wasm-pack --target web
- 8 tests pass, clippy = 0 on wasm32 target
Closes #156)

- Delete extension/sidepanel.js, background.js, style.css (L9 violation)
- Add crates/trios-ext/src/dom.rs: full UI builder (Total Black, gold accent)
- Add crates/trios-ext/src/mcp.rs: WebSocket MCP client to trios-server:9005
- Add crates/trios-ext/src/bg.rs: Chrome sidePanel API via JS interop
- Update manifest.json: WASM service worker, content security policy
- Update sidepanel.html: loads WASM module (no inline logic)
- Add extension/bg-sw.js: 3-line WASM loader (auto-glue, not handwritten logic)
- WASM builds with wasm-pack --target web
- 8 tests pass, clippy = 0 warnings on wasm32 target
… CI artifact checks

- Delete scripts/build_phase2a.sh and scripts/test_real_bpb.sh (L1 violation)
- Add CI step to check no handwritten JS in extension/ outside dist/ (L9)
- Remove CI checks for deleted background.js and style.css
- Refs #156
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.

🚨 P0 VIOLATION: JS in extension/ — ALL extension code MUST be Rust → WASM (no .js handwritten)

1 participant