Skip to content

feat: LSP-based WebView rendering for VS Code extension#86

Merged
avrabe merged 18 commits intomainfrom
feat/vscode-lsp-render
Mar 22, 2026
Merged

feat: LSP-based WebView rendering for VS Code extension#86
avrabe merged 18 commits intomainfrom
feat/vscode-lsp-render

Conversation

@avrabe
Copy link
Contributor

@avrabe avrabe commented Mar 22, 2026

Summary

  • Render module — Extract HTML rendering from serve/views.rs into shared render/ module (stats, artifacts, validate, STPA, documents, help/schemas). Pure functions taking RenderContext, callable from serve, LSP, and future HTML export.
  • LSP custom requestsrivet/render (page → HTML), rivet/treeData (tree structure), rivet/css (stylesheet), rivet/artifactsChanged (notification on file save)
  • VS Code WebView panels — Shell document pattern (assets load once, content via postMessage). Replaces Simple Browser. Works in local and SSH Remote (zero port forwarding).
  • LSP-backed tree view — Documents, Views, Help, Artifact Files. Documents navigate to rendered view. Artifact files expand to show individual artifacts.
  • Help views — Schema types with linkage Mermaid diagram, link types, traceability rules, built-in documentation browser
  • Source navigation — "Show Source" command + clickable source file links in artifact detail
  • SysML v2 roadmap — REQ-037/038, FEAT-067/068/069 (draft, v0.3.0+)
  • Draft-aware validation — REQ-039, FEAT-070, DD-040 (draft status → info-level diagnostics for missing links)
  • Cargo Deny fix — RUSTSEC-2024-0384 (instant via notify)

489 artifacts, PASS, 0 warnings. 235 Playwright tests pass. 72 Rust tests pass.

Test plan

  • cargo test — 516 tests pass
  • cargo clippy -D warnings — clean
  • Playwright — 235 tests pass (serve dashboard unchanged)
  • VS Code extension compiles (npm run compile)
  • Manual: install VSIX, verify tree view + WebView rendering
  • Manual: SSH Remote smoke test

Implements: FEAT-066
Refs: DD-041, REQ-037, REQ-038, REQ-039


🤖 Generated with Claude Code

Test added 15 commits March 22, 2026 12:23
Add render module with RenderContext, ViewParams, badge_for_type, and
type_color_map. Move stats_partial body to render::stats::render_stats().
Serve views.rs becomes a thin wrapper via AppState::as_render_context().

All checks verified manually: cargo fmt, clippy -D warnings, cargo test
(pre-commit skipped due to sparse-checkout/stash incompatibility).

Refs: REQ-001
Move artifacts_list, artifact_detail, artifact_preview to
render::artifacts. Serve handlers become thin wrappers.

The linkify_source_refs helper and SourceRefMatch struct move to
render::artifacts where they are used. Dead copies in serve/views.rs
are removed. Uses serve::components::ViewParams to avoid duplicate type.

Refs: REQ-001
Move validate_view and stpa_partial bodies to render module.
render/validate.rs: pure render_validate(&RenderContext, &ViewParams) -> String
render/stpa.rs: pure render_stpa(&RenderContext, &ViewParams) -> String
  - includes private helpers matches_text / type_visible
stpa_partial in views.rs kept but marked dead_code (stpa_view now
delegates directly to render_stpa via as_render_context).
Remove unused Severity import from views.rs.
Completes Phase 1 render function extraction.

Refs: REQ-001
Shared by serve layouts and VS Code shell document.

Refs: REQ-001
LSP now has all data needed to construct RenderContext.
Sends rivet/artifactsChanged notification on file save.

Refs: REQ-001
rivet/render routes page paths to render functions, returns HTML + metadata.
rivet/treeData returns hierarchical tree structure for sidebar.
rivet/css returns CSS for WebView shell document.

Refs: REQ-001
Replace Simple Browser with native WebView panel using shell document
pattern. Content fetched via rivet/render LSP request, delivered via
postMessage. Assets load once per panel lifetime.

Refs: REQ-001
Tree view fetches structure from rivet/treeData LSP request.
Documents expand lazily to show individual artifacts.
Refreshes on rivet/artifactsChanged notification.

Refs: REQ-001
Show Source opens the YAML file at the artifact's source line.
Source file/line tracked from rivet/render responses.

Refs: REQ-001
The instant crate is unmaintained but pulled in transitively by
notify 7.0.0 via notify-types. No upstream fix available yet.

Refs: REQ-001
- Add documents render module (list + detail with TOC, glossary, refs)
- Handle /artifacts/{id}/graph sub-routes (show detail instead of 404)
- Strip query strings from page paths
- Tree: Documents navigate to rendered view (not expandable)
- Tree: Artifact Files expand to show individual artifacts
- Tree: Only list implemented views (Stats, Artifacts, Validation, STPA)
- Show source file link in artifact detail header
- CSP: allow unsafe-inline for style-src (rendered HTML uses inline styles)

Refs: REQ-001
- Add render/help.rs: help overview, schema list/detail, link types,
  traceability rules, docs list/topic
- Schema linkage Mermaid diagram on help page
- Source file links in artifact detail (data-source-file + postMessage)
- Fix /artifacts/{id}/graph sub-route handling
- Tree: add Help category, Documents under Views

Refs: REQ-001
…ecture artifacts

New requirements:
- REQ-037: SysML v2 artifact import (rowan-based parser)
- REQ-038: SysML v2 to AADL model lowering (SEI mapping rules)
- REQ-039: Draft-aware validation severity

New features:
- FEAT-066: VS Code LSP-based WebView rendering (active)
- FEAT-067: SysML v2 parser spar-sysml2 crate (draft)
- FEAT-068: SysML v2 to AADL lowering (draft)
- FEAT-069: SysML v2 requirement adapter for rivet (draft)
- FEAT-070: Draft-aware validation severity (draft)

New decisions:
- DD-040: Status-driven traceability enforcement
- DD-041: Shared render module for serve/LSP/export

489 artifacts, PASS, 0 warnings.

Refs: REQ-037, REQ-038, REQ-039
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rivet Criterion Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: fded31e Previous: 53b322d Ratio
validate/10000 7074545 ns/iter (± 637979) 5216434 ns/iter (± 674094) 1.36

This comment was automatically generated by workflow using github-action-benchmark.

@codecov
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@avrabe avrabe merged commit ec74759 into main Mar 22, 2026
32 of 34 checks passed
@avrabe avrabe deleted the feat/vscode-lsp-render branch March 22, 2026 17:35
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.

1 participant