fix: kipy 0.7.x / KiCad 10 IPC backend compatibility (IPC 后端兼容修复) - #378
fix: kipy 0.7.x / KiCad 10 IPC backend compatibility (IPC 后端兼容修复)#378AlloyPlane wants to merge 1 commit into
Conversation
- ipc_backend: KiCad() auto-connect + get_version() verification (ping times out) - ipc_backend: get_open_documents(DocumentType.DOCTYPE_PCB) + board_filename path resolution - ipc_backend: load footprints by .pretty dir (GetGlobalFootprintLib removed in KiCad 10) - kicad_interface: _ipc_place_component falls back componentId when footprint param missing - command-timeout: treat open_project/create_project/open_board/place_component as long-running
|
Reviewed. The kipy 0.7 / KiCad 10 claims are plausible and consistent with what #369 independently found, and the two-arg pcbnew.FootprintLoad(libPath, fpName) call is the correct KiCad 10 signature. But there is one blocker and two structural asks before this can merge. Blocker — hardcoded developer-machine paths. _pretty_dirs() ships two absolute D:\ paths from your own portable install (D:\kicad\share\kicad\footprints as the default for the env-var escape hatch, and D:\kicad\custom-lib unconditionally), plus Windows-only separators that mean nothing on macOS/Linux. On every other user's machine this silently probes the wrong disk. The correct replacement already exists in this repo: python/commands/library.py has _get_global_fp_lib_table() (line 60) and _parse_fp_lib_table() (line 84), with platform roots handled by python/utils/platform_helper.py. Route footprint discovery through fp-lib-table and hand the resolved .pretty directory to the two-arg FootprintLoad — only the path discovery needs replacing, the load call itself is right. Second: this adds a third copy of the DocumentSpecifier decoding (#369's in get_open_board_path, yours in _place_loaded_footprint, plus the legacy doc.path fallback). Factor one helper and use it at both sites — three copies is exactly how the next kipy break gets fixed in one place and missed in two. Relatedly, the legacy hasattr(doc, 'path') check now sits after an unconditional break and reads as dead code; restructure so the fallback is explicit. Third: src/command-timeout.ts promotes eight commands to the long-running bucket, including the read-only get_component_list and get_board_info. That changes a hang from a 30 s failure into a 10-minute wait on queries. Justify those two per-command or drop them. And tests: #369 shipped a 138-line test file for a 12-line change to this same subsystem; hold this to that bar (the DocumentSpecifier helper is easily unit-testable with fakes). A CHANGELOG entry (English, under Unreleased) is also missing. The IPC-compat work itself is wanted — #357 collides with this same territory on a stale base, and a corrected version of this PR is the better vehicle. |
修复内容 / What this fixes
让 KiCAD-MCP-Server 的 IPC 后端在 kicad-python 0.7.x + KiCad 10 环境下可用(实时 UI 同步)。
Fixes the IPC backend so it works with kicad-python 0.7.x + KiCad 10 (real-time UI sync).
问题 / Problem
在 KiCad 10.0.5 + kicad-python 0.7.1 下,IPC 后端连接失败并静默回退到 SWIG(
_realtime: false),因为服务器代码针对的是旧版 kipy API。另外 KiCad 10 移除了
pcbnew.GetGlobalFootprintLib。Under KiCad 10.0.5 + kicad-python 0.7.1, the IPC backend fails to connect and silently
falls back to SWIG (
_realtime: false), because the server code targets an older kipy API.Also, KiCad 10 removed
pcbnew.GetGlobalFootprintLib.改动 / Changes
KiCad()自动拨号 + 用get_version()验证(新 kipy 的ping()会超时)KiCad()auto-dial + verify viaget_version()(new kipy'sping()times out)get_open_documents(DocumentType.DOCTYPE_PCB)(新 kipy 需要参数),并用
board_filename+project.path组装板文件路径(DocumentSpecifier已无path字段)get_open_documents(DocumentType.DOCTYPE_PCB)(new kipy requires the arg) and assemble theboard path from
board_filename+project.path(no morepathfield on DocumentSpecifier).pretty目录pcbnew.FootprintLoad(KiCad 10 移除了
GetGlobalFootprintLib)load footprints by
.prettydir path (KiCad 10 removedGetGlobalFootprintLib)footprint参数缺失时回退到componentIdfall back to
componentIdwhen thefootprintparam is missingopen_project/create_project/open_board/place_component等加入长时命令列表(SWIG 初始化可能超过 30s)
treat
open_project/create_project/open_board/place_componentas long-running(SWIG init can exceed 30s)
测试 / Testing
open_project→_backend: "ipc",_realtime: true(实时会话)place_component→ 成功,KiCad GUI 实时显示(含自定义库封装)npm run build通过;冒烟测试通过相关 / Related
中文说明:本 PR 修复 KiCad 10 + kicad-python 0.7.x 环境下 IPC 实时控制不可用的问题,共 5 处改动,
已在 Windows 上实测(实时放件成功)。如有任何格式或命名规范问题,请告知,我会调整。谢谢!