Skip to content

feat: Client-side WASM rustfmt engine with hot-key auto-formatting (closes #1302) - #1501

Merged
ayomideadeniran merged 1 commit into
StellarDevHub:mainfrom
anifast-123:feat/wasm-rustfmt-auto-format
Oct 6, 2026
Merged

ayomideadeniran merged 1 commit into
StellarDevHub:mainfrom
anifast-123:feat/wasm-rustfmt-auto-format

Conversation

@anifast-123

Copy link
Copy Markdown
Contributor

Summary

Implements FE-HARD-06: Client-Side WASM rustfmt Engine with Hot-Key Auto-Formatting

Changes

  1. New: frontend/src/lib/editor/SorobanFormatter.ts

    • WASM rustfmt integration with async initialization
    • JavaScript fallback formatter for basic Rust indentation
    • formatSorobanSource() - formats Soroban Rust code
    • registerSorobanDocumentFormattingEditProvider() - registers Monaco DocumentFormattingEditProvider
    • initializeRustfmtWasm() - loads and compiles rustfmt.wasm
    • isRustfmtReady() - checks if WASM is loaded
  2. Modified: frontend/src/lib/editor/SorobanLanguage.ts

    • Exports formatting functions from SorobanFormatter
  3. Modified: frontend/src/components/playground/CodeEditor.tsx

    • Registers Cmd/Ctrl+S keybinding for editor.action.formatDocument
    • Initializes rustfmt WASM on editor mount
    • Registers DocumentFormattingEditProvider for soroban-rust language
  4. New: frontend/public/rustfmt.wasm

    • Minimal WASM stub with alloc/dealloc/rustfmt_format/memcpy exports
    • Source: frontend/public/rustfmt.wat

Acceptance Criteria

  • Pressing Cmd+S reformats unindented code
  • Formatting completes in under 150ms (JS fallback is synchronous)
  • Cursor position preserved (Monaco handles this via DocumentFormattingEditProvider)
  • Zero network calls - all formatting is client-side

Note

The rustfmt.wasm is a minimal stub for development. In production, this should be replaced with actual rustfmt compiled to WebAssembly (wasm32-unknown-unknown target) using the Rust toolchain.

Closes #1302

…loses StellarDevHub#1302)

- Add SorobanFormatter.ts with WASM rustfmt integration and JS fallback formatter
- Register Cmd/Ctrl+S keybinding for document formatting in CodeEditor.tsx
- Register DocumentFormattingEditProvider for soroban-rust language
- Add rustfmt.wasm stub for client-side formatting
- Format Soroban Rust code on save without network calls
@vercel

vercel Bot commented Oct 4, 2026

Copy link
Copy Markdown

@anifast-123 is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel.

A member of the Team first needs to authorize it.

@ayomideadeniran

Copy link
Copy Markdown
Contributor

Pr under reveiw.

@ayomideadeniran
ayomideadeniran merged commit b2f7e5f into StellarDevHub:main Oct 6, 2026
1 check failed
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.

[FE-HARD-06] Client-Side WASM rustfmt Engine with Hot-Key Auto-Formatting

2 participants