Fix the BLE auto connection bug.#36
Merged
9 commits merged intoJun 22, 2026
Merged
Conversation
JSON-RPC 2.0 over stdio 插件骨架,rebased 到 upstream/main 新结构:
* AhaKeyPluginKit (library)
- JSONRPC.swift 协议类型 (JSONValue / Request / Response / Error)
- PluginClient.swift actor 客户端 (readabilityHandler 事件驱动 stdin/stdout)
- PluginHost.swift host/* 方法 + 权限白名单
- PluginLifecycle.swift initialize / initialized / shutdown / exit
- PluginManifest.swift plugin.json + ${pluginDir} 占位符
- PluginManager.swift 扫描目录、批量加载、错误隔离
* Plugin (executable demo)
- `swift run Plugin` 跑一遍 PluginManager 流程
- 用 AHAKEY_PLUGINS_DIR 指定插件目录
* AhaKeyConfig 主 app
- dependencies 加 AhaKeyPluginKit (可直接 import)
- exclude AhaKeyPlugin / AhaKeyPluginKit 避免被当成主 app sources
兼容 macOS 12:URL(filePath:) 全部改回 URL(fileURLWithPath:)
A small background plugin that polls the physical switch state once a second, counts auto/manual flips, tracks per-mode dwell time, and exposes demo/flowStats. Falls back to ~/.ahakey-fake-lever when no agent/keyboard is reachable, so it can be demoed without hardware. Wired into the SDK build / typecheck / clean scripts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ci.yml runs on push/PR: TypeScript SDK typecheck + tests, compile-check all Swift targets, then package the macOS app and upload it as an artifact. package_app.sh assembles AhaKeyConfig into an ad-hoc signed "AhaKey Studio.app", shared by local builds and CI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Examples resolve @ahakey/plugin-sdk via package self-reference to dist/index.d.ts, but dist/ is gitignored and absent on a clean CI checkout, so `npm run typecheck` failed with "Cannot find module '@ahakey/plugin-sdk'". Make typecheck self-contained by running build:sdk first, the same way the test script already builds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…stream layout Upstream/main 把多平台目录从 platforms/<os>/ 拍扁成 ahakeyconfig-<os>/。 这一 commit 只做目录重命名,路径里引用 platforms/macos 的脚本/CI/docs 留到下一个 commit 处理。
Update platforms/macos -> ahakeyconfig-mac in path references that belonged to feat/plugin's own commits (TS SDK npm scripts, CI workflow working-directory, package_app.sh comments). README/CHANGELOG/ docs path references are left for the upcoming merge with upstream/main to overwrite, since upstream already rewrote them.
Upstream/main 新增内容: - bf49f5a: 灯效自定义 + 4 Mode + 权限延迟 + 编辑态优化 (AhakeyAI#33) - README/CHANGELOG/docs 全部重写以反映多平台目录布局 (AhakeyAI#35) - LICENSE 改为 placeholder(待与上游统一) 冲突解决: - ahakeyconfig-mac/Sources/Agent/AhaKeyAgent.swift:人手 3-way merge 保留 HEAD 的 hasLiveSocket() 检测 + Bool 返回值 (避免双 agent) 并入 upstream 的 startWatchdog() 调用 - 6 个文件 (HookClient/AhaKeyConfigApp/AhaKeyStudioView/ContentView/ generate_dmg_background.swift/generate_icons.swift):feat/plugin 本身没改过内容,直接接受 upstream 版本 - Makefile + VibeCodeKeyboard.ico:跟随 upstream 搬到 repo root - cursor_0.gif + build.local.env*:接受上游删除
c518f9f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. 背景
针对 #34(macOS 一直「等待设备」,系统蓝牙/语音可用但 Studio 扫不到),
以及连接、刷新方面的一组可靠性问题。
2. 改动(4 个独立修复)
链路诊断 + 宽 service 兜底(macOS: AhaKey Studio 一直扫描中,系统蓝牙和语音可用但界面等待设备 #34)
LinkDiagnostic,把笼统的「等待设备」拆成可区分状态:蓝牙未开/无权限、配置链路(0x7340)未连、已连 HID/语音但配置链路未连、Agent 占用中、未发现设备。
顶栏 pill 展示,hover 有可操作详情。
connectAutomatically()改用更宽的标准 service 集合(0x7340 / 180A / 180F / 1812)retrieve 系统已连接设备并主动 connect,
didConnect再 discover 0x7340。识别
vibe code固件名vibe code XXXX,而 app/agent 只认AhaKey前缀 → 被过滤。改为前缀白名单
["AhaKey", "vibe code"]+matchesDeviceName(),app 与 agent 一致。Agent 起不来时自动回退 App 直连
agent,卡在「Agent 占用中」需手动重连。改为 load+start 后用真实
connect()探测等socket,超时仍无则释放占用、App 直连(死 socket 不再误判为 agent 存活)。
修复状态轮询永久卡死
sendCommandAwaitingResponse超时只throw、不 resume 挂着的CheckedContinuation,withThrowingTaskGroup会一直等它 → 函数不返回、defer不清理、protocolResponseWaiters残留 → 1.5s 状态轮询被guard ...isEmpty永久挡死(设备某模式不回应即触发,表现为页面不随键盘刷新、必须重连)。超时改为原子移除并 resume。
3. 测试
swift build通过vibe code B1D2端到端验证:开机自动连上;状态轮询每 ~1.5s 跑、实时捕捉档位变化(3→0);agent 失效 plist 场景下自动回退 App 直连。
但精确复现「系统已连但完全不在 retrieve 列表」的边界仍需更多设备验证。
4. 关联
Closes #34
5. Type of change / 修改类型
请选择本次 PR 的类型。
Please select the type of this PR.
6. Area / 涉及范围
请选择本次修改涉及的部分。
Please select the area affected by this PR.