Open-source Revit MCP server: let Claude and other AI assistants read and edit BIM models, with human approval on every change.
Python aecai-agentsautodeskautomationbimclaudeifcmcpmcp-servermodel-context-protocolnavisworksrevitrevit-addinrevit-apirhino
feat(panel): finish token gaps, live Revit theme sync, and align design docs
sammohammad5789575d95f51f4
diff --git a/docs/0011-panel-architecture.md b/docs/0011-panel-architecture.mdindex 2e46637..39c9848 100644--- a/docs/0011-panel-architecture.md+++ b/docs/0011-panel-architecture.md@@ -4,7 +4,7 @@Accepted## Context-Standard Revit add-ins built with WPF (Windows Presentation Foundation) suffer from development friction, lack of modern CSS/animation styling capabilities, and poor cross-platform portability. In addition, loading native assemblies into Revit's single-threaded app domain carries risk of thread locks and assembly load-order clashes. To deliver a modern, premium user interface (dark mode, glassmorphism, responsive chat, plan diff lists) that is portable across Revit, Rhino, and Navisworks, we need a WebView2-based panel architecture.+Standard Revit add-ins built with WPF (Windows Presentation Foundation) suffer from development friction, lack of modern CSS/animation styling capabilities, and poor cross-platform portability. In addition, loading native assemblies into Revit's single-threaded app domain carries risk of thread locks and assembly load-order clashes. To deliver a modern user interface (a dark theme that follows Revit, restrained glass surfaces, responsive chat, a plan approval queue) that is portable across Revit, Rhino, and Navisworks, we need a WebView2-based panel architecture. The visual design has since shipped; §4 records what it is. `docs/design/tokens.md` is the concrete spec.## Decisions@@ -50,9 +50,15 @@ To maintain security boundaries while enabling rapid data transfer:- **Non-blocking UI**: The Web App runs entirely inside the isolated WebView2 process. Rendering complex graphs, SVG models, or parsing large log files does not block Revit's single-threaded user interface.- **API Threading Dispatch**: Commands requiring access to Revit API objects are passed over the WebView2 Host Bridge, enqueued on `CommandQueue.Enqueue`, and raised via `ExternalEvent.Raise()` to execute on Revit's main API thread inside a standard Transaction.-### 4. UI Design Philosophy & Frameworks-- **Styling**: Pure Vanilla CSS tailored with rich aesthetic HSL variables (sleek dark mode default, subtle micro-animations for hover states, glassmorphism card layouts).-- **No Heavy Frameworks**: Minimal javascript boilerplate; native Web Components or a lightweight view-scheduler (e.g., standard template strings) to avoid load-time lag.+### 4. UI Design System & Frameworks+- **Design tokens**: `docs/design/tokens.md` (approved) is the single source of truth for the brand mark, color, typography, surfaces, motion and the ribbon icon grammar. There is no codegen or token-sync tool. Values are hand-copied into `panel/styles.css` (as `--amb-*` CSS custom properties), `IconGenerator.cs` and `assets/logo.svg`, and each copy site carries a `keep in sync with docs/design/tokens.md` comment.+- **Brand mark**: "The Span", two bearings joined by a deck under a brand-colored apex. It replaces the three disagreeing cube/gradient marks. It appears as an inline SVG in the panel rail, as the ribbon brand icon, and in `assets/logo.svg`.+- **Theming**: Light and dark palettes, each with its own verified contrast. The panel follows **Revit's** theme, not only the OS theme. The add-in sends `isDarkTheme` (from `UIThemeManager.CurrentTheme`) in every `host.status` message, and `app.js` sets `data-theme` on `<html>`. `prefers-color-scheme` is only a fallback until the first `host.status` arrives. A mid-session Revit theme toggle re-themes the panel live: the add-in subscribes to Revit's `ThemeChanged` event (Revit 2024+, guarded for older versions) and sends a fresh `host.status`. Ribbon icons are the exception. They are generated once at startup, so they show the theme Revit had at session start and only change after a full Revit restart. This is a known, accepted limitation.+- **Surfaces**: Only two surfaces get the glass treatment: the topbar (`--amb-glass` fill plus `--amb-glass-filter`) and the rail (`--amb-glass-filter` over its always-dark `--amb-rail` fill). Cards, inputs and list rows stay opaque so body text stays legible. This narrows the original "glassmorphism card layouts" idea on purpose. Elevation uses two shadow tokens. A single `:focus-visible` ring is the universal focus affordance.+- **Semantic color**: One set of semantic tokens (danger, warning, info, success, pending, idle) drives both the panel badges and the ribbon icons. `pending` (plans waiting for approval) is violet on both.+- **Motion**: Two motion tokens (`--amb-motion-fast` for hover/press, `--amb-motion-view` for view switches). All animation and transitions are turned off under `prefers-reduced-motion: reduce`.+- **Typography**: Segoe UI / system-ui only, with no webfont. A webfont would flash each time the docked pane opens. Run-log timestamps use tabular numerals.+- **No Heavy Frameworks**: Vanilla HTML/CSS/JS with template strings, and no bundler, so the pane loads without lag.## Consequences- **Rapid Iteration**: UI changes, styling patches, and log viewer additions can be made and tested inside standard web browsers without needing to restart the Revit host application.diff --git a/docs/design/tokens.md b/docs/design/tokens.mdindex be83f6f..9c56d3f 100644--- a/docs/design/tokens.md+++ b/docs/design/tokens.md@@ -1,6 +1,6 @@# AEC Model Bridge — design tokens-Status: **proposed**, pending maintainer approval.+Status: **approved**.Scope: the brand mark, the color system, typography, and the ribbon icongrammar for `assets/logo.svg`, `packages/revit-bridge-addin/src/UI/IconGenerator.cs`,and `panel/styles.css`.@@ -261,8 +261,11 @@ disabled nav item, an unavailable provider.**Implementer note for Task 7:** `panel/app.js` `renderPlans()` hardcodes`class="badge pending"` while printing `plan.status` as the label, so a planwhose status is `approved` currently renders a violet "approved" badge. Map the-status string to a token class (`approved` → `success`, `rejected` → `danger`,-`pending`/anything else → `pending`) at the same time.+status string to a token class (`approved` → `success`, `rejected` → `error`,+`pending`/anything else → `pending`) at the same time. The rejected class is+`error`, not `danger`: badge classes follow the severity-badge naming+(`.badge.error` is the one painted with `--amb-danger`), and there is no+`.badge.danger` class.### 3.6 Badge treatmentdiff --git a/packages/revit-bridge-addin/src/Bridge/App.cs b/packages/revit-bridge-addin/src/Bridge/App.csindex 0823391..d8b628e 100644--- a/packages/revit-bridge-addin/src/Bridge/App.cs+++ b/packages/revit-bridge-addin/src/Bridge/App.cs@@ -137,6 +137,10 @@ namespace RevitBridge.Bridgestring reportsIconPath32 = Path.Combine(iconPath, "reports_32.png");// Generate theme-adaptive icons, then retain in-memory fallbacks if file I/O fails.+ // Known, accepted limitation: ribbon icons reflect the Revit theme at session+ // start only. The dockable panel re-themes live on ThemeChanged+ // (BridgePanelProvider), but the ribbon needs a full Revit restart (not just a+ // panel reload) to pick up a theme change.try{IconGenerator.GenerateAllIcons(iconPath);diff --git a/packages/revit-bridge-addin/src/UI/BridgePanel.xaml.cs b/packages/revit-bridge-addin/src/UI/BridgePanel.xaml.csindex cbc7223..11ffe55 100644--- a/packages/revit-bridge-addin/src/UI/BridgePanel.xaml.cs+++ b/packages/revit-bridge-addin/src/UI/BridgePanel.xaml.cs@@ -274,6 +274,32 @@ namespace RevitBridge.UI}}+ /// <summary>+ /// Called when Revit's UI theme changes mid-session (subscribed in+ /// BridgePanelProvider.Register) so the panel re-themes live via a fresh+ /// host.status. Only the panel updates live - ribbon icons are generated+ /// once at startup (see App.CreateModernRibbonInterface).+ /// </summary>+ internal void OnRevitThemeChanged()+ {+ Dispatcher.BeginInvoke(new Action(() =>+ {+ if (!_pageReady)+ {+ return;+ }++ try+ {+ PostHostStatus();+ }+ catch (Exception ex)+ {+ Log.Warning(ex, "Failed to post host status after Revit theme change");+ }+ }));+ }+private void PostHostStatus(){var dirtyCount = DocumentDirtyTracker.GetDirtyUniqueIds().Count;diff --git a/packages/revit-bridge-addin/src/UI/BridgePanelProvider.cs b/packages/revit-bridge-addin/src/UI/BridgePanelProvider.csindex e13c2e8..5e1eb75 100644--- a/packages/revit-bridge-addin/src/UI/BridgePanelProvider.cs+++ b/packages/revit-bridge-addin/src/UI/BridgePanelProvider.cs@@ -16,6 +16,27 @@ namespace RevitBridge.UI{application.RegisterDockablePane(PaneId, "AEC Model Bridge", new BridgePanelProvider());Log.Information("AEC Model Bridge dockable pane registered");++ // Guarded like IconGenerator.IsDarkTheme(): ThemeChanged only exists on+ // Revit 2024+. The reference lives in its own non-inlined method so a+ // missing event surfaces as a catchable MissingMemberException here+ // rather than a JIT failure of Register itself.+ try+ {+ SubscribeToThemeChanged(application);+ }+ catch (Exception ex)+ {+ Log.Information(ex, "Revit theme-change event unavailable; panel theme syncs on next host status only");+ }+ }++ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]+ private static void SubscribeToThemeChanged(UIControlledApplication application)+ {+ // Push a fresh host.status (which carries isDarkTheme) the moment the+ // user toggles Revit's theme, instead of waiting for their next click.+ application.ThemeChanged += (_, _) => _panel?.OnRevitThemeChanged();}public static bool Show(UIApplication application, out string error, string view = "", string action = "")diff --git a/panel/styles.css b/panel/styles.cssindex a0c772f..40d37f5 100644--- a/panel/styles.css+++ b/panel/styles.css@@ -26,10 +26,19 @@--amb-glass-filter: blur(14px) saturate(120%);--amb-shadow-1: 0 1px 2px rgba(16, 24, 40, 0.08);--amb-shadow-2: 0 6px 16px rgba(16, 24, 40, 0.10);+ --amb-motion-fast: 120ms cubic-bezier(.4, 0, .2, 1); /* hover, press */+ --amb-motion-view: 180ms cubic-bezier(.2, .7, .3, 1); /* view switch */+}++/* Narrow color-scheme once Revit's theme is known, so native controls+ (select popups, scrollbars) follow Revit rather than the OS. */+:root[data-theme="light"] {+ color-scheme: light;}:root[data-theme="dark"] {/* keep in sync with docs/design/tokens.md */+ color-scheme: dark;--amb-ink: #E9EEF5;--amb-ink-muted: #9BA8B9;--amb-bg: #14181E;@@ -89,6 +98,8 @@}}+@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }+* {box-sizing: border-box;}@@ -158,7 +169,7 @@ select {place-items: center;gap: 3px;font-size: 10px;- letter-spacing: 0;+ letter-spacing: 0.06em;}.brand-mark {@@ -381,6 +392,11 @@ p {margin-bottom: 4px;}+/* Run-log timestamps: tabular figures so the column doesn't shift (tokens.md §4). */+.event .meta {+ font-variant-numeric: tabular-nums;+}+.composer {display: grid;grid-template-columns: auto minmax(0, 1fr) auto auto;@@ -398,6 +414,14 @@ p {border-color: var(--amb-brand);background: var(--amb-brand);color: var(--amb-on-brand);+ transition: background-color var(--amb-motion-fast), border-color var(--amb-motion-fast);+}++.composer button:hover:not(:disabled),+.settings button:hover:not(:disabled),+[data-action="approve-selected"]:hover:not(:disabled) {+ border-color: var(--amb-brand-strong);+ background: var(--amb-brand-strong);}.item {