Improve Buddy Bluetooth recovery and signing#187
Open
Lakphy wants to merge 9 commits into
Open
Conversation
Co-authored-by: Copilot <copilot@github.com>
- Introduced `*_Question` functions in multiple mascot header files to enable a question alert mode. - Updated `drawBang` function to render a question mark when `_questionMode` is active. - Modified `clawdSleep` to include a bored yawn animation based on global bored state. - Added global variables for bored state and eye offset to enhance mascot behavior. - Implemented tool icon classification and drawing functions for better visual representation of tools.
- Updated ESP32BridgeManager to handle legacy pairing fallback and timeout scenarios. - Improved error messages and status handling for pairing states. - Added new payload for clearing tool history. - Enhanced localization strings for better user guidance. - Updated README with clearer pairing instructions and hints for legacy firmware mode. - Added tests for new functionality in AppState and ESP32Protocol.
nguyenvanduocit
pushed a commit
to nguyenvanduocit/CodeIsland
that referenced
this pull request
May 22, 2026
…ilure modes No new upstream commits since May 10. Two new user reports (wxtsky#185, wxtsky#186) document a second failure mode in T-056: the display picker in Settings only shows the built-in Retina Display and never surfaces external monitors in active dual-display mode. Updated T-056 criteria to cover both the jump and the missing-picker-entry scenarios. Also documents new upstream items (PR wxtsky#187 ESP32, issue wxtsky#188 companion concept) as out of scope. https://claude.ai/code/session_01GkndnzUrzdzTD2NvXFHmob
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.
中文说明
摘要
这个 PR 增强了 Buddy 桌宠的 macOS 端 BLE 桥接、ESP32 固件协议和硬件文档,目标是让 Buddy 在配对、重连、状态同步和桌宠屏幕信息展示上更稳定、更可诊断。
核心变更包括:
hostId,固件端保存已配对主机,首次连接需要在 Buddy 上按 BOOT 物理确认。.withResponse写入配对请求,写失败或新固件无响应不会再误判成 legacy connected;只有只支持WRITE_NR的旧固件才进入 legacy fallback。connId,替换硬编码disconnect(0),避免在连接 id 不是 0 时无法断开被拒绝/重置的客户端。macOS 端变更说明
Buddy 相关 macOS 端变更:
ESP32BridgeManager:负责 Buddy 扫描、选择、配对、重连、写队列、button/control uplink 分发。ESP32StatePublisher:将当前岛上展示的 session 状态同步到 Buddy,并推送扩展信息帧。SettingsView/L10n:展示 pairing / waiting confirm / rejected / legacy firmware 等 Buddy 状态和提示。ESP32Protocol:集中定义 Buddy BLE 协议和 payload 编解码,降低 Mac 端与固件端协议漂移风险。涉及 macOS 端但不是 Buddy UI/桥接本体的改动及必要性:
SessionSnapshot.totalToolCallCount:这是共享会话模型字段,不是 Buddy 专用 UI。它是必要的,因为 Buddy 只保留最近工具历史用于屏幕展示,而统计面板需要累计工具调用总数;如果直接使用截断后的toolHistory.count,Buddy 显示的工具统计会越来越不准确。scripts/build-dmg.sh:增加 Xcode.app toolchain 选择和 ad-hoc 签名 fallback。Buddy Bluetooth 在 macOS 上依赖 signed.appbundle 和 Bluetooth entitlement;当本机没有 Developer ID 证书或使用SKIP_SIGN=1做本地验证时,仍需要对 app/nested Sparkle helpers 做 ad-hoc signing,避免 CoreBluetooth 权限和本地调试行为与真实 app 不一致。scripts/dev-hot-restart.sh与 README 提示:明确 bare executable 不能代表 Buddy Bluetooth 的真实运行环境。这样可以避免开发者用swift build && ./.build/debug/CodeIsland测 Buddy 时遇到权限问题却误以为是 BLE 或固件问题。ClineView的#Preview加#if DEBUG:这是生产构建清理,不改变运行时功能;它避免 release/signing 构建路径包含 SwiftUI preview-only 代码,减少 app bundle 构建和签名流程中的非业务噪音。固件/硬件变更说明
验证
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test通过,320 tests。DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test --filter 'ESP32BridgeManagerQueueTests|AppStatePrimarySourceTests|ESP32ProtocolTests'通过,53 tests。git diff --check通过。arduino-cli,本 PR 已做源码级检查,并确认disconnect(0)已清除。English Description
Summary
This PR improves the Buddy desktop pet integration across the macOS BLE bridge, ESP32 firmware protocol, and hardware documentation. The goal is to make Buddy pairing, reconnect recovery, status synchronization, and on-device status panels more reliable and easier to diagnose.
Main changes:
hostId, firmware stores the paired host, and first-time pairing requires physical BOOT-button confirmation on Buddy..withResponsefor pair requests, and failed/no-response acknowledged writes no longer fall through into legacy connected mode. Legacy fallback is limited to firmware that only supportsWRITE_NR.connIdinstead of hard-codingdisconnect(0).macOS Changes
Buddy-specific macOS changes:
ESP32BridgeManager: scanning, selection, pairing, reconnects, prioritized write queue, and Buddy uplink dispatch.ESP32StatePublisher: pushes the currently displayed island session state and richer metadata frames to Buddy.SettingsView/L10n: shows pairing, confirmation, rejection, reconnecting, and legacy firmware states in Settings.ESP32Protocol: centralizes Buddy BLE payload definitions and encoding/decoding to keep macOS and firmware behavior aligned.macOS-side changes that are not Buddy UI/bridge code, and why they are necessary:
SessionSnapshot.totalToolCallCount: this is a shared session model change rather than Buddy UI code. It is needed because Buddy keeps a bounded recent tool history for display, while the stats panel needs an accumulated tool-call count. Reusing the truncated history length would make Buddy stats drift lower over long sessions.scripts/build-dmg.sh: selects the Xcode.app toolchain and adds ad-hoc signing fallback. Buddy Bluetooth on macOS needs a signed.appbundle with Bluetooth entitlements. When a Developer ID certificate is unavailable, local builds still need ad-hoc signing for the app and nested Sparkle helpers so CoreBluetooth permission behavior matches the real app environment.scripts/dev-hot-restart.shand README notes: document that launching a bare executable is not a valid Buddy Bluetooth test environment. This prevents Bluetooth entitlement failures from being mistaken for BLE or firmware regressions.ClineView#PreviewDEBUG guard: this is production build hygiene and does not change runtime behavior. It keeps SwiftUI preview-only declarations out of release/signing paths, reducing unrelated noise in app bundle builds.Firmware / Hardware Changes
Validation
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift testpassed, 320 tests.DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test --filter 'ESP32BridgeManagerQueueTests|AppStatePrimarySourceTests|ESP32ProtocolTests'passed, 53 tests.git diff --checkpassed.arduino-cliis not available in this environment. Source-level checks were performed, and all hard-codeddisconnect(0)calls have been removed.