Commit graph

48 commits

Author SHA1 Message Date
Stuart
514551c9f2 CMMS fork: AI bridge reads the project from IndexedDB, not the globals
Console showed buildProjectView reporting "4 photos" but NO
buildProjectImages line at all - it was hitting the silent
`!bomImages.length` early return. The studio.js bomData/bomImages
globals get transiently emptied while a project loads / auto-stitches,
and the get-buffer handler's `await` between buildProjectView and
buildProjectImages is enough of a yield to catch that window.

- buildProjectView + buildProjectImages + applyProjectPatch now call
  db.getComponents/getImages/getNets(currentBomId) directly instead of
  reading bomData/bomImages/bomList.
- buildProjectImages traces on entry ("start (board: ...)") and after
  the DB read ("N image record(s)") so an empty result is never silent.
2026-09-03 15:35:16 +10:00
Stuart
8976c52f42 CMMS fork: robust board-photo encoding for the AI bridge
read_board_image reported "no board photos available" - buildProjectImages
was returning [] (both photos failed to encode) with no visibility.

- split encodeImage into downscale() + blobToB64(); on any failure
  (createImageBitmap / canvas.toBlob returning null / EXIF-heavy JPEGs)
  fall back to sending the raw blob base64 if it's under ~3MB.
- coerce a non-Blob img.blob through new Blob([...]).
- per-image [cmms-pcb-bridge] tracing: "downscaled ok" / "downscale
  failed: <msg> - trying raw" / "raw encode also failed" etc.
2026-09-03 15:31:06 +10:00
Stuart
40373493b5 CMMS fork: hand the board photos to the AI bridge
The board photos live in pcb-retrace's IndexedDB, not as CMMS
attachments, so the assistant had no way to see them and burned all its
tool-call rounds looking. cmms-bridge.js now downscales each project
photo (long edge ~1400px, JPEG q0.8 - a phone photo lands under ~300KB)
and sends them alongside the buffer in the cmms-ai-editor-buffer reply
as `images: [{id,name,mime,data_base64}]` (max 6). The CMMS
read_board_image tool surfaces one at a time.
2026-09-03 15:23:17 +10:00
Stuart
04d29dc0ac CMMS fork: pcb AI bridge — robustness for the first-message race
The chat's get-buffer request can arrive before studio.js init() has
built the DB / selected a board (or while an existing project ZIP is
still streaming in), which read back as "the editor is still loading".

- buildProjectView() waits up to 4.5s for db + a board, then still
  returns a valid (possibly empty) project view with a "no board open"
  note rather than null - only a missing db is "still loading".
- init() with no loadUrl (a "+ New board RE") now ensures a starter
  board exists (studio.js only auto-creates one when the whole DB is
  empty, not when the selected device just has no boards).
- reply prefers evt.source, falls back to a DOM query for the chat
  iframe (cad-editor hit an unusable cross-realm Window).
- [cmms-pcb-bridge] console tracing on every step.
2026-09-03 15:09:33 +10:00
Stuart
c15ba490b2 CMMS fork: AI Assistant editor-buffer bridge (pcb kind)
cmms-bridge.js gains a window 'message' listener answering the CMMS AI
assistant's cmms-ai-editor-* protocol (same role as cad-editor's Rust
listener, since studio.html is the top-level page here):

- cmms-ai-editor-get-buffer  -> replies { type:'cmms-ai-editor-buffer',
  buffer: <JSON> } — device/board name, placed components
  ({label,value,desc,x,y}), nets ({name,pins:[...]}), and the imported
  board-photo list.
- cmms-ai-editor-apply (editor:'pcb') -> parses a JSON patch of proposed
  components + nets and merges it into the open project (upsert components
  by label, nets by name; new parts with no coordinate are staggered so
  they're draggable; net pins inherit their component's position if it
  exists). Refreshes the BOM list / map / nets view. Nothing is saved -
  the user checks each against the board photo and clicks Save.

Inert unless window.PCBRETRACE_CONFIG is set.
2026-09-03 14:48:55 +10:00
Stuart
8bf5fd3a9a CMMS fork: embedding hooks (window.PCBRETRACE_CONFIG)
New docs/cmms-bridge.js — inert unless window.PCBRETRACE_CONFIG is present
(only public/vendor/pcb-retrace/edit.php in the CMMS sets it). When set:
- injects "Save" / "Save & close" into the top bar; hides the standalone
  import/export/share buttons.
- on boot, if config.loadUrl is set, pulls the project .pcbretrace.zip
  from the CMMS and restores it silently (reuses processUrlImport).
- Save builds the whole-device ZIP in memory and POSTs it multipart to
  the CMMS attachment endpoint (action/csrf/job_id/id/original_name/file,
  same contract as circuit-edit.php); first save of a new board switches
  to in-place updates.

studio.js:
- exportDeviceZIP() split into buildDeviceZIP(pass, forCmms) -> {blob,
  filename} + a thin exportDeviceZIP() wrapper. forCmms adjusts the
  embedded README + manifest.source.
- importFile/processZIP/processUrlImport take an opts arg; opts.silent
  skips the restore/import confirms and re-throws instead of alert().
- init() awaits window.CMMS.init() at the end when present.

studio.html: loads cmms-bridge.js (defer, after studio.js).

Standalone pcb.etaras.com / local use is unchanged — every new path is
gated on the config object or opts.silent, both absent by default.
Dark mode: config.dark is recorded as data-theme="dark" but studio.html
is light-only today; CMMS-theme-follow is a later task.
2026-09-03 14:16:42 +10:00
Stuart
5e4c7245b6 CMMS fork: re-vendor all runtime deps locally, strip analytics
Upstream loads zip.js, OpenCV.js, WireBender (JS+WASM) and Google Fonts
from CDNs at runtime, and includes a Google Tag / gtag.js snippet. The
CMMS deployment forbids external requests. Changes:

- docs/vendor/ — local copies of opencv.js (Apache-2.0), zip.min.js
  (BSD-3-Clause), WireBender.{js,wasm} (AGPL-3.0/commercial, source at
  github.com/dev-lab/WireBender), and the three Google fonts (OFL, latin
  subset). SOURCE.txt records provenance.
- studio.html / schema.html — zip.js + opencv.js + fonts @import point at
  docs/vendor/.
- inspect-traces.js / schema/layout.js — WireBender import() + locateFile
  point at docs/vendor/wirebender/.
- every *.html — Google Tag / gtag.js snippet removed.

No behaviour change; kicad-symbols zip was already bundled + local.
CMMS embedding hooks (window.PCBRETRACE_CONFIG, save-back, AI bridge)
land in a later commit.
2026-09-03 14:02:16 +10:00
Taras Greben
e3d1052faa tune linguist to not skip docs 2026-08-27 23:35:45 +03:00
Taras Greben
ff4ac844d0 Navigation (history) from modal boxes fixed. 2026-07-10 13:45:28 +03:00
Taras Greben
da0bd681e1 Ignore net attributes to improve schematic diagrams (eliminate wierd bus routing in some cases). 2026-07-10 12:02:46 +03:00
Taras Greben
b4977b2c2a Ignore release script. 2026-07-03 18:11:45 +03:00
Taras Greben
c5e66e8b97 Sort Nets and Components lists in Schema ReTrace, navigate through items using Up/Down keys. 2026-07-03 17:54:47 +03:00
Taras Greben
d27e2ca267 Add Re-route button to Schema ReTrace. 2026-07-03 17:16:21 +03:00
Taras Greben
ce2106feaa Don't let Schema ReTrace panic over 3-leg diodes or caps. 2026-07-03 14:40:02 +03:00
Taras Greben
10c3fda73b Changed PCB calculated trace styling to an old-school pre-SMD look. 2026-07-02 22:27:12 +03:00
Taras Greben
114c983b08 Fixed the sticky node name validator issue, where a validator used once was incorrectly reused for all input text dialogs. Added a new feature: the Inspector view now shows calculated routes for nets, including inactive ones. 2026-07-01 17:38:52 +03:00
Taras Greben
b92a021734 Fix KiCAD netlist export if more than one projects are managed 2026-06-26 15:39:02 +03:00
Taras Greben
f3bb3b4408 make sure await is prior to .length 2026-06-26 14:53:45 +03:00
Taras Greben
70104b33ac Fix OpenCV Mat leak when stitching/connecting PCB images 2026-06-26 14:33:12 +03:00
Taras Greben
6e8079dd50 Typo fixed: Math.Pi 2026-06-26 13:57:09 +03:00
Taras Greben
ad01bdd74f reverted version 2026-05-23 12:38:07 +03:00
Taras Greben
12a2682c8f set right cla assistant lite version 2026-05-23 12:21:31 +03:00
dev-lab
1bb12066c2
chore: add missing copyright headers 2026-05-23 12:13:05 +03:00
dev-lab
55236223f8 chore: automatically enrich source files with copyright headers 2026-05-23 09:09:46 +00:00
Taras Greben
d76aea27b8 bumb action plugin version 2026-05-23 12:07:26 +03:00
Taras Greben
6fd3922c0a worflow action version fixed (can't use only major) 2026-05-23 11:47:23 +03:00
Taras Greben
4e6d9d9800 bump workflow actions versions 2026-05-23 11:43:50 +03:00
Taras Greben
0a0f9ff9fd AES-256 encryption option for project files, progress on importing KiCad symbols 2026-05-23 11:18:19 +03:00
dev-lab
41939fb47c
Merge pull request #4 from dev-lab/chore/add-license-headers
chore: add missing copyright headers
2026-05-07 17:50:41 +03:00
dev-lab
995a5d178c chore: automatically enrich source files with copyright headers 2026-05-07 14:47:37 +00:00
Taras Greben
6ea81337ec Add exclusions to license action 2026-05-07 17:45:50 +03:00
Taras Greben
642bc207f0 Add license workflow 2026-05-07 17:13:05 +03:00
Taras Greben
df5607bfa8 Nets validator added. 2026-04-27 18:02:04 +03:00
Taras Greben
d156954156 Fix race condition that prevented comp/net count to be shown. 2026-04-27 00:34:24 +03:00
Taras Greben
e5da28c468 don't ignore kicad library zip in git 2026-04-24 17:33:54 +03:00
Taras Greben
d7b4a6c499 Schema ReTrace added (create schematic diagrams from netlists). 2026-04-24 17:28:59 +03:00
Taras Greben
33d9820785 favicon added 2026-01-30 23:48:18 +02:00
Taras Greben
b4d4ff1f83 Updated guide Step 3: Tracing Nets 2025-12-26 15:07:21 +02:00
Taras Greben
8266a8e81f Major upgrate to Inspector/Netlist workflow: the tool now intelligently suggests node names if components defined, also added collapsible cheat sheet for pins numbering 2025-12-26 14:55:08 +02:00
Taras Greben
46d538e55f Added references to examples 2025-12-22 20:46:44 +02:00
Taras Greben
d69d18d797 Manual stitching default point locations fixed in Flip Target mode 2025-12-22 18:45:13 +02:00
Taras Greben
0022cb6a3a Inspector layout improved, Deep Linking implemented 2025-12-22 16:56:46 +02:00
Taras Greben
e852547d01 When showing Inspect view, fit images to client area initially 2025-12-21 19:59:28 +02:00
Taras Greben
8cd74dd1b4 Tweaked generic input modal style, Nets column width on phones 2025-12-21 19:07:02 +02:00
Taras Greben
ca9fe52db5 Fixed manual image stitching and Inspector view for mobiles, other minor fixes/improvements. 2025-12-21 18:45:40 +02:00
Taras Greben
55e55edee9 PCB ReTrace initial 2025-12-21 00:55:01 +02:00
dev-lab
2752bd3b6a
Create CNAME 2025-12-21 00:40:17 +02:00
Taras Greben
f06b8a68b8 PCB ReTrace initial 2025-12-21 00:31:26 +02:00