app
KiCad - the KiCad Bridge
Public Made by Adomby adom
Reference implementation of the KiCad bridge: multi-instance Python server, forward path via kicad-cli, reverse path via in-process plugin. Most complex of the three bundled bridges.
← Commit history
Publish 1.0.91
4 files changed
+24−17
dashboard/kicad_dashboard.py+12−3@@ -49,7 +49,7 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from pathlib import Path from urllib.parse import unquote, urlparse -VERSION = "4.0.2"+VERSION = "4.1.0" AI_THREAD = "kicad-dashboard" DEFAULT_PORT = 8931 UI_DIR = Path(__file__).resolve().parent / "ui"@@ -1198,8 +1198,17 @@ class Handler(BaseHTTPRequestHandler): try: # any other GET renders the app (proxy-friendly: sub-paths still work) # no-store: the dock's Hard Refresh Open must never get a cached # shell after a version bump (dockbar guide).- return self._send(200, "text/html; charset=utf-8",- (UI_DIR / "index.html").read_text(encoding="utf-8"),+ # Inject the phrase list at SERVE time. It comes from dockbar.json,+ # which is static config, so making the panel wait on an /api round+ # trip only created a boot race: on first paint the target is not+ # resolved yet, the call came back empty, and the page rendered NO+ # panel at all - the same "panel with no prompts" shape the fleet+ # audit kept finding elsewhere. Static data belongs in the document.+ html = (UI_DIR / "index.html").read_text(encoding="utf-8")+ html = html.replace("</head>",+ "<script>window.__SAY_PHRASES__=" ++ json.dumps(say_phrases()) + ";</script></head>", 1)+ return self._send(200, "text/html; charset=utf-8", html, {"Cache-Control": "no-store, must-revalidate"}) except Exception as e: return self._json({"error": f"ui missing: {e}"}, 500)
dashboard/ui/index.html+10−12@@ -578,23 +578,21 @@ $('#btnClose').onclick=async()=>{toast('closing the bridge\u2019s KiCad windows' // Phrases come from dockbar.json `say` via the server, then the MODULE owns // everything else: card, grid, table, icons, clipboard, send, toasts, X and // the header toggle. We only tell it our noun and what the demo does.-async function buildSay(){- // Two things can be late at boot: the phrase list (act() rides the selected- // target, which loadTargets() has not resolved yet on first paint) and the- // module <script>. Either being late used to leave the page with NO panel,- // silently - the same "panel with no prompts" shape the fleet audit kept- // finding on other apps. So poll for both, briefly, instead of returning.- const attempt=async()=>{+function buildSay(){+ // Phrases are injected into the document at serve time (window.__SAY_PHRASES__),+ // so there is no fetch to race at boot. The module may still be a moment+ // behind if its <script> is slow, so poll briefly for it rather than+ // returning and leaving the page with no panel.+ const phrases=(window.__SAY_PHRASES__||[]).slice(0,6);+ if(!phrases.length)return;+ const attempt=()=>{ if(!window.AdomNewbiePanel)return false;- let phrases=[];- try{const r=await act('say');phrases=((r.data||r).phrases)||[];}catch(e){}- if(!phrases.length)return false; try{ doMount(phrases); }catch(e){ console.error('newbie panel mount failed',e); } return true; };- if(await attempt())return;+ if(attempt())return; let tries=0;- const t=setInterval(async()=>{ if(await attempt()||++tries>20)clearInterval(t); },400);+ const t=setInterval(()=>{ if(attempt()||++tries>20)clearInterval(t); },250); } function doMount(phrases){ AdomNewbiePanel.mount({
package.json+1−1@@ -1,6 +1,6 @@ { "slug": "kicad-bridge",- "version": "1.0.90",+ "version": "1.0.91", "type": "app", "description": "Skills for your container so your AI knows how to drive the KiCad bridge. The bridge runtime itself is the release zip; Adom Bridge loads that.", "tags": [
page.json+1−1@@ -4,7 +4,7 @@ "slug": "kicad-bridge", "title": "KiCad - the KiCad Bridge", "brief": "Reference implementation of the KiCad bridge — multi-instance Python server, forward path via kicad-cli, reverse path via in-process plugin. Most complex of the three bundled bridges.",- "version": "1.0.90",+ "version": "1.0.91", "tags": [ "kicad", "pcb",