Skip to content

Open-source Revit MCP server: let Claude and other AI assistants read and edit BIM models, with human approval on every change.

feat(panel): add static WebView panel app (P16.2)

A. Sam Mohammad0a0d233622d1
diff --git a/packages/revit-bridge-addin/RevitBridge.csproj b/packages/revit-bridge-addin/RevitBridge.csproj
index 24b6e58..f8be388 100644
--- a/packages/revit-bridge-addin/RevitBridge.csproj
+++ b/packages/revit-bridge-addin/RevitBridge.csproj
@@ -57,6 +57,13 @@
<PackageReference Include="IronPython" Version="3.4.1" Condition="'$(TargetFramework)'!='net48'" />
</ItemGroup>
+ <ItemGroup>
+ <Content Include="..\..\panel\**\*">
+ <Link>panel\%(RecursiveDir)%(Filename)%(Extension)</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+
<!-- .NET Framework requires explicit WPF references; modern SDK targets use UseWPF. -->
<ItemGroup Condition="'$(TargetFramework)'=='net48'">
<Reference Include="PresentationCore" />
diff --git a/packages/revit-bridge-addin/src/UI/BridgePanel.xaml.cs b/packages/revit-bridge-addin/src/UI/BridgePanel.xaml.cs
index b8eb7ca..58976f0 100644
--- a/packages/revit-bridge-addin/src/UI/BridgePanel.xaml.cs
+++ b/packages/revit-bridge-addin/src/UI/BridgePanel.xaml.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows;
@@ -32,7 +33,7 @@ namespace RevitBridge.UI
{
await Browser.EnsureCoreWebView2Async();
Browser.CoreWebView2.WebMessageReceived += OnWebMessageReceived;
- Browser.NavigateToString(BuildShellHtml());
+ LoadPanelApp();
}
catch (Exception ex)
{
@@ -73,6 +74,18 @@ namespace RevitBridge.UI
Browser.CoreWebView2?.PostWebMessageAsJson(payload);
}
+ private void LoadPanelApp()
+ {
+ var panelPath = Path.Combine(AppContext.BaseDirectory, "panel", "index.html");
+ if (File.Exists(panelPath))
+ {
+ Browser.Source = new Uri(panelPath);
+ return;
+ }
+
+ Browser.NavigateToString(BuildShellHtml());
+ }
+
private static string BuildShellHtml()
{
return @"
diff --git a/panel/app.js b/panel/app.js
new file mode 100644
index 0000000..b65a30a
--- /dev/null
+++ b/panel/app.js
@@ -0,0 +1,226 @@
+const views = {
+ chat: { title: "Chat", subtitle: "AEC Model Bridge" },
+ plans: { title: "Pending Actions", subtitle: "Approval queue" },
+ findings: { title: "Findings", subtitle: "Model health" },
+ log: { title: "Run Log", subtitle: "Recent activity" },
+ settings: { title: "Settings", subtitle: "Local bridge" }
+};
+
+const state = {
+ host: null,
+ plans: [
+ {
+ id: "plan_demo_01",
+ title: "Set FireRating on 12 doors",
+ status: "pending",
+ detail: "Parameter Manager will write FireRating = 60 to matching door instances."
+ },
+ {
+ id: "plan_demo_02",
+ title: "Rename duplicate sheet numbers",
+ status: "pending",
+ detail: "QA/QC checker found duplicate sheet numbers in the active document."
+ }
+ ],
+ findings: [
+ { id: "f-001", severity: "error", title: "Doors missing FireRating", detail: "12 door instances have an empty FireRating value." },
+ { id: "f-002", severity: "warning", title: "Views not on sheets", detail: "8 views are not placed on sheets." },
+ { id: "f-003", severity: "info", title: "Unplaced rooms", detail: "3 rooms are unplaced in the active model." }
+ ],
+ log: [
+ { at: "09:00", title: "Panel loaded", detail: "Waiting for host status." }
+ ]
+};
+
+const hostStatus = document.getElementById("host-status");
+const title = document.getElementById("view-title");
+const subtitle = document.getElementById("view-subtitle");
+const chatFeed = document.getElementById("chat-feed");
+const chatForm = document.getElementById("chat-form");
+const chatInput = document.getElementById("chat-input");
+const planList = document.getElementById("plan-list");
+const findingList = document.getElementById("finding-list");
+const runLog = document.getElementById("run-log");
+const severityFilter = document.getElementById("severity-filter");
+const settingsForm = document.getElementById("settings-form");
+const hubUrl = document.getElementById("hub-url");
+
+function postToHost(type, payload = {}) {
+ if (window.chrome && window.chrome.webview) {
+ window.chrome.webview.postMessage(JSON.stringify({ type, ...payload }));
+ }
+}
+
+function escapeHtml(value) {
+ return String(value).replace(/[&<>"']/g, (char) => ({
+ "&": "&amp;",
+ "<": "&lt;",
+ ">": "&gt;",
+ "\"": "&quot;",
+ "'": "&#39;"
+ })[char]);
+}
+
+function addLog(titleText, detail) {
+ state.log.unshift({
+ at: new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }),
+ title: titleText,
+ detail
+ });
+ renderLog();
+}
+
+function setView(viewName) {
+ document.querySelectorAll(".nav").forEach((button) => {
+ button.classList.toggle("is-active", button.dataset.view === viewName);
+ });
+ document.querySelectorAll(".view").forEach((view) => {
+ view.classList.toggle("is-active", view.id === `view-${viewName}`);
+ });
+ title.textContent = views[viewName].title;
+ subtitle.textContent = views[viewName].subtitle;
+}
+
+function renderHostStatus() {
+ const online = state.host?.serverRunning;
+ hostStatus.classList.toggle("is-online", !!online);
+ hostStatus.lastElementChild.textContent = online
+ ? `Revit ${state.host.revitVersion || ""} :${state.host.port || ""}`
+ : "Host pending";
+}
+
+function renderChat() {
+ chatFeed.innerHTML = "";
+ [
+ { role: "assistant", text: "Ready for the active model." },
+ { role: "assistant", text: "Pending plans and findings will appear in their tabs." }
+ ].forEach((message) => appendMessage(message.role, message.text));
+}
+
+function appendMessage(role, text) {
+ const item = document.createElement("article");
+ item.className = `message ${role === "user" ? "user" : "assistant"}`;
+ item.innerHTML = `<div class="meta">${role === "user" ? "You" : "AMB"}</div><div>${escapeHtml(text)}</div>`;
+ chatFeed.appendChild(item);
+ chatFeed.scrollTop = chatFeed.scrollHeight;
+}
+
+function renderPlans() {
+ planList.innerHTML = "";
+ state.plans.forEach((plan) => {
+ const item = document.createElement("article");
+ item.className = "item";
+ item.innerHTML = `
+ <div class="item-head">
+ <h2>${escapeHtml(plan.title)}</h2>
+ <span class="badge pending">${escapeHtml(plan.status)}</span>
+ </div>
+ <p>${escapeHtml(plan.detail)}</p>
+ <div class="item-actions">
+ <button type="button" data-plan="${escapeHtml(plan.id)}" data-decision="approve">Approve</button>
+ <button type="button" data-plan="${escapeHtml(plan.id)}" data-decision="reject">Reject</button>
+ </div>`;
+ planList.appendChild(item);
+ });
+}
+
+function renderFindings() {
+ findingList.innerHTML = "";
+ const severity = severityFilter.value;
+ state.findings
+ .filter((finding) => severity === "all" || finding.severity === severity)
+ .forEach((finding) => {
+ const item = document.createElement("article");
+ item.className = "item";
+ item.innerHTML = `
+ <div class="item-head">
+ <h2>${escapeHtml(finding.title)}</h2>
+ <span class="badge ${escapeHtml(finding.severity)}">${escapeHtml(finding.severity)}</span>
+ </div>
+ <p>${escapeHtml(finding.detail)}</p>`;
+ findingList.appendChild(item);
+ });
+}
+
+function renderLog() {
+ runLog.innerHTML = "";
+ state.log.forEach((event) => {
+ const item = document.createElement("article");
+ item.className = "event";
+ item.innerHTML = `<div class="meta">${escapeHtml(event.at)}</div><strong>${escapeHtml(event.title)}</strong><p>${escapeHtml(event.detail)}</p>`;
+ runLog.appendChild(item);
+ });
+}
+
+document.querySelectorAll(".nav").forEach((button) => {
+ button.addEventListener("click", () => setView(button.dataset.view));
+});
+
+document.body.addEventListener("click", (event) => {
+ const target = event.target;
+ if (!(target instanceof HTMLElement)) {
+ return;
+ }
+
+ const action = target.dataset.action;
+ if (action === "refresh-plans") {
+ postToHost("plans.refresh");
+ addLog("Plans refreshed", "Requested pending plans from the host.");
+ }
+ if (action === "approve-selected") {
+ postToHost("plans.approveSelected");
+ addLog("Approval requested", "Selected pending actions sent to the host.");
+ }
+ if (action === "run-health") {
+ postToHost("qaqc.runHealthCheck");
+ addLog("Health check requested", "QA/QC run sent to the host.");
+ }
+
+ const planId = target.dataset.plan;
+ if (planId) {
+ const decision = target.dataset.decision;
+ postToHost(`plan.${decision}`, { planId });
+ addLog(`Plan ${decision}`, planId);
+ }
+});
+
+chatForm.addEventListener("submit", (event) => {
+ event.preventDefault();
+ const text = chatInput.value.trim();
+ if (!text) {
+ return;
+ }
+ appendMessage("user", text);
+ chatInput.value = "";
+ postToHost("chat.message", { text });
+ appendMessage("assistant", "Request sent to the host.");
+ addLog("Chat message sent", text);
+});
+
+severityFilter.addEventListener("change", renderFindings);
+
+settingsForm.addEventListener("submit", (event) => {
+ event.preventDefault();
+ postToHost("settings.save", {
+ hubUrl: hubUrl.value,
+ approvalMode: document.getElementById("approval-mode").value
+ });
+ addLog("Settings saved", hubUrl.value);
+});
+
+if (window.chrome && window.chrome.webview) {
+ window.chrome.webview.addEventListener("message", (event) => {
+ if (event.data?.type === "host.status") {
+ state.host = event.data;
+ renderHostStatus();
+ addLog("Host status updated", state.host.activeDocument || "No active document");
+ }
+ });
+}
+
+renderChat();
+renderPlans();
+renderFindings();
+renderLog();
+renderHostStatus();
+postToHost("panel.loaded");
diff --git a/panel/index.html b/panel/index.html
new file mode 100644
index 0000000..3780cc1
--- /dev/null
+++ b/panel/index.html
@@ -0,0 +1,97 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>AEC Model Bridge</title>
+ <link rel="stylesheet" href="./styles.css">
+</head>
+<body>
+ <aside class="rail" aria-label="Primary">
+ <div class="brand" aria-label="AEC Model Bridge">
+ <span class="brand-mark" aria-hidden="true"></span>
+ <span>AMB</span>
+ </div>
+ <button class="nav is-active" type="button" data-view="chat" title="Chat" aria-label="Chat">
+ <span aria-hidden="true">C</span>
+ </button>
+ <button class="nav" type="button" data-view="plans" title="Plans" aria-label="Plans">
+ <span aria-hidden="true">P</span>
+ </button>
+ <button class="nav" type="button" data-view="findings" title="Findings" aria-label="Findings">
+ <span aria-hidden="true">F</span>
+ </button>
+ <button class="nav" type="button" data-view="log" title="Run Log" aria-label="Run Log">
+ <span aria-hidden="true">L</span>
+ </button>
+ <button class="nav" type="button" data-view="settings" title="Settings" aria-label="Settings">
+ <span aria-hidden="true">S</span>
+ </button>
+ </aside>
+
+ <main class="app">
+ <header class="topbar">
+ <div>
+ <h1 id="view-title">Chat</h1>
+ <p id="view-subtitle">AEC Model Bridge</p>
+ </div>
+ <div class="status-pill" id="host-status">
+ <span class="dot"></span>
+ <span>Host pending</span>
+ </div>
+ </header>
+
+ <section class="view is-active" id="view-chat" aria-labelledby="view-title">
+ <div class="chat-feed" id="chat-feed"></div>
+ <form class="composer" id="chat-form">
+ <input id="chat-input" name="message" autocomplete="off" placeholder="Ask about the active model">
+ <button type="submit">Send</button>
+ </form>
+ </section>
+
+ <section class="view" id="view-plans" aria-labelledby="view-title">
+ <div class="toolbar">
+ <button type="button" data-action="refresh-plans">Refresh</button>
+ <button type="button" data-action="approve-selected">Approve Selected</button>
+ </div>
+ <div class="list" id="plan-list"></div>
+ </section>
+
+ <section class="view" id="view-findings" aria-labelledby="view-title">
+ <div class="toolbar">
+ <button type="button" data-action="run-health">Run Health Check</button>
+ <select id="severity-filter" aria-label="Severity">
+ <option value="all">All severities</option>
+ <option value="error">Errors</option>
+ <option value="warning">Warnings</option>
+ <option value="info">Info</option>
+ </select>
+ </div>
+ <div class="list" id="finding-list"></div>
+ </section>
+
+ <section class="view" id="view-log" aria-labelledby="view-title">
+ <div class="timeline" id="run-log"></div>
+ </section>
+
+ <section class="view" id="view-settings" aria-labelledby="view-title">
+ <form class="settings" id="settings-form">
+ <label>
+ Hub URL
+ <input id="hub-url" value="http://127.0.0.1:3000">
+ </label>
+ <label>
+ Approval Mode
+ <select id="approval-mode">
+ <option value="required">Required</option>
+ <option value="auto">Auto</option>
+ </select>
+ </label>
+ <button type="submit">Save</button>
+ </form>
+ </section>
+ </main>
+
+ <script src="./app.js"></script>
+</body>
+</html>
diff --git a/panel/styles.css b/panel/styles.css
new file mode 100644
index 0000000..a81e732
--- /dev/null
+++ b/panel/styles.css
@@ -0,0 +1,322 @@
+:root {
+ color-scheme: light dark;
+ font-family: "Segoe UI", system-ui, sans-serif;
+ --bg: #f4f6f8;
+ --surface: #ffffff;
+ --surface-alt: #eef2f7;
+ --line: #d7dde6;
+ --text: #18202c;
+ --muted: #5b6676;
+ --blue: #2563eb;
+ --green: #0f8a5f;
+ --amber: #b7791f;
+ --red: #c2413a;
+ --shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
+}
+
+* {
+ box-sizing: border-box;
+}
+
+body {
+ margin: 0;
+ min-width: 320px;
+ min-height: 100vh;
+ display: grid;
+ grid-template-columns: 58px minmax(0, 1fr);
+ background: var(--bg);
+ color: var(--text);
+}
+
+button,
+input,
+select {
+ font: inherit;
+}
+
+button {
+ border: 1px solid var(--line);
+ border-radius: 6px;
+ background: var(--surface);
+ color: var(--text);
+ min-height: 34px;
+ padding: 0 12px;
+ cursor: pointer;
+}
+
+button:hover {
+ border-color: var(--blue);
+}
+
+input,
+select {
+ min-height: 36px;
+ width: 100%;
+ border: 1px solid var(--line);
+ border-radius: 6px;
+ padding: 0 10px;
+ background: var(--surface);
+ color: var(--text);
+}
+
+.rail {
+ display: grid;
+ grid-template-rows: 58px repeat(5, 44px) 1fr;
+ gap: 6px;
+ padding: 8px;
+ border-right: 1px solid var(--line);
+ background: #18202c;
+ color: white;
+}
+
+.brand {
+ display: grid;
+ place-items: center;
+ gap: 3px;
+ font-size: 10px;
+ letter-spacing: 0;
+}
+
+.brand-mark {
+ width: 26px;
+ height: 26px;
+ border-radius: 7px;
+ background:
+ linear-gradient(135deg, #14b8a6 0 48%, transparent 49%),
+ linear-gradient(225deg, #2563eb 0 48%, transparent 49%),
+ linear-gradient(45deg, #8b5cf6 0 48%, transparent 49%);
+ box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
+}
+
+.nav {
+ width: 42px;
+ min-height: 40px;
+ padding: 0;
+ border-color: transparent;
+ background: transparent;
+ color: #dbeafe;
+}
+
+.nav.is-active,
+.nav:hover {
+ background: rgba(255, 255, 255, 0.12);
+ color: white;
+}
+
+.app {
+ min-width: 0;
+ display: grid;
+ grid-template-rows: 64px minmax(0, 1fr);
+}
+
+.topbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 12px 16px;
+ border-bottom: 1px solid var(--line);
+ background: var(--surface);
+}
+
+h1 {
+ margin: 0;
+ font-size: 18px;
+ line-height: 1.2;
+ font-weight: 650;
+}
+
+p {
+ margin: 4px 0 0;
+ color: var(--muted);
+ font-size: 12px;
+}
+
+.status-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ min-height: 30px;
+ padding: 0 10px;
+ border: 1px solid var(--line);
+ border-radius: 999px;
+ background: var(--surface-alt);
+ color: var(--muted);
+ font-size: 12px;
+ white-space: nowrap;
+}
+
+.dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: var(--amber);
+}
+
+.status-pill.is-online .dot {
+ background: var(--green);
+}
+
+.view {
+ min-height: 0;
+ display: none;
+ padding: 14px;
+ overflow: auto;
+}
+
+.view.is-active {
+ display: grid;
+ align-content: start;
+ gap: 12px;
+}
+
+.toolbar {
+ display: flex;
+ gap: 8px;
+ flex-wrap: wrap;
+ align-items: center;
+}
+
+.toolbar select {
+ max-width: 180px;
+}
+
+.chat-feed,
+.list,
+.timeline {
+ display: grid;
+ gap: 10px;
+}
+
+.chat-feed {
+ align-content: end;
+ min-height: 320px;
+}
+
+.message,
+.item,
+.event {
+ border: 1px solid var(--line);
+ border-radius: 8px;
+ background: var(--surface);
+ box-shadow: var(--shadow);
+}
+
+.message {
+ padding: 10px 12px;
+ max-width: 86%;
+}
+
+.message.user {
+ justify-self: end;
+ border-color: #bfdbfe;
+ background: #eff6ff;
+}
+
+.message .meta,
+.event .meta {
+ color: var(--muted);
+ font-size: 11px;
+ margin-bottom: 4px;
+}
+
+.composer {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto;
+ gap: 8px;
+}
+
+.composer button,
+.settings button,
+[data-action="approve-selected"] {
+ border-color: var(--blue);
+ background: var(--blue);
+ color: white;
+}
+
+.item {
+ padding: 12px;
+}
+
+.item-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+}
+
+.item h2 {
+ margin: 0;
+ font-size: 14px;
+ line-height: 1.3;
+}
+
+.badge {
+ border-radius: 999px;
+ padding: 3px 8px;
+ color: white;
+ font-size: 11px;
+ text-transform: uppercase;
+}
+
+.badge.error {
+ background: var(--red);
+}
+
+.badge.warning {
+ background: var(--amber);
+}
+
+.badge.info {
+ background: var(--blue);
+}
+
+.badge.pending {
+ background: #64748b;
+}
+
+.item p {
+ font-size: 13px;
+ line-height: 1.45;
+}
+
+.item-actions {
+ display: flex;
+ gap: 8px;
+ flex-wrap: wrap;
+ margin-top: 10px;
+}
+
+.event {
+ padding: 10px 12px;
+}
+
+.settings {
+ display: grid;
+ gap: 12px;
+ max-width: 520px;
+}
+
+.settings label {
+ display: grid;
+ gap: 6px;
+ color: var(--muted);
+ font-size: 12px;
+}
+
+@media (prefers-color-scheme: dark) {
+ :root {
+ --bg: #202124;
+ --surface: #2a2d33;
+ --surface-alt: #343942;
+ --line: #414753;
+ --text: #f4f6f8;
+ --muted: #b7c0cc;
+ --shadow: none;
+ }
+
+ .message.user {
+ background: #172554;
+ border-color: #1d4ed8;
+ }
+}