Skip to content

Evolve BLE tab into Connection tab with default-layer and OS-detection support#90

Open
cormoran wants to merge 4 commits into
mainfrom
claude/connection-tab
Open

Evolve BLE tab into Connection tab with default-layer and OS-detection support#90
cormoran wants to merge 4 commits into
mainfrom
claude/connection-tab

Conversation

@cormoran

@cormoran cormoran commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

Renames the BLE tab to Connection (IconPlugConnected, tab id connection) and extends it to integrate three ZMK modules:

Module Subsystem identifier Status
zmk-module-ble-management cormoran_ble already integrated, UI carried over unchanged
zmk-feature-os-detection cormoran__os_detection new
zmk-feature-default-layer cormoran__default_layer new

UI sections (top to bottom)

  • Header — Connection title + refresh button that reloads all three subsystems and layer names.
  • Status strip — current effective OS (OsBadge), active connection, and resolved default layer.
  • Output Priority — unchanged from the BLE tab, including the disconnect warning dialog.
  • Connections — USB card (connected state, detected OS, default-layer select) followed by BLE profile cards. Each paired profile card keeps all existing ble-management controls (rename, switch, unpair, active highlight) and gains a second row with an OS override select (Auto / Windows / macOS / Linux / iOS / Android, with a detected: X caption when overridden) and a default-layer select (Unset / OS detection / <layer names>).
  • Per-OS Default Layers — one row per OS (Unknown/Windows/macOS/Linux/iOS/Android) with layer selects; the current OS row is highlighted.
  • Help box — notes that BLE OS detection is heuristic and links the three module repos.

Graceful degradation

Every subsystem is optional and every section renders only if its subsystem exists, with per-section hints instead of a full-page block:

  • ble-management missing → existing hint card kept, but USB card and simple "BLE profile N" rows are still built from default-layer endpoints / os-detection profiles (pure merge helper, unit-tested) so layer/override config still works.
  • default-layer missing → Per-OS section body becomes an availability hint linking zmk-feature-default-layer.
  • firmware built without OS detection (os_detection_available=false) → per-OS selects disabled with a hint linking zmk-feature-os-detection.
  • OS enum conversion between the raw zmk_os (default-layer proto) and the os-detection proto enum (protoOs = zmkOs + 1) is centralized in src/lib/osDetection.ts.

Implementation

  • Protos copied to proto/cormoran/{os_detection,default_layer}/ with committed buf-generated code in src/proto/.
  • New hooks: useOsDetection (auto-load + 5s poll, no notifications in firmware), useDefaultLayer (set responses carry full state, applied directly without refetch), useLayerNames (lightweight keymap-name fetch).
  • New components: OsBadge, LayerSelect.
  • Demo transport: stateful demo-os-detection.ts / demo-default-layer.ts handlers registered in demo.ts, so the demo UI is fully interactive; also fixed inverted isOpen flags in the demo BLE fixtures.
  • All user-facing strings go through t() with Japanese translations.

Test coverage

  • useOsDetection / useDefaultLayer hook tests: encode/decode, sentinel handling (-1/-2), set→state update semantics, 5s polling and cleanup on unmount.
  • mergeConnectionCards unit tests covering all subsystem-availability combinations and label priority.
  • ConnectionPage tests (17): carried-over BLE behaviors (switch/unpair/rename with 31-char limit), status strip, OS override firing SetBleOverride with the correct enum, per-OS selects disabled when os_detection_available=false, USB card, and BLE rows derived without ble-management.
  • npm run lint, npm test (27 suites, 234 passed / 1 pre-existing skip), and npm run build all pass. Manually verified in demo mode: all sections render and select changes round-trip through the demo handlers.

🤖 Generated with Claude Code

codex and others added 4 commits July 6, 2026 11:17
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Also fix inverted isOpen flags in the demo BLE profile fixtures so
paired profiles (MacBook Pro, iPad) show as paired in demo mode.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…n UI

Renames BLEConnectionsPage to ConnectionPage and extends it with a
status strip, USB card, per-profile OS override and default-layer
selects, and a per-OS default layers section. Each section degrades
gracefully when its subsystem is unavailable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

🚀 Cloudflare Workers Preview

Preview URL: https://137e6cf6-dya-studio.cormoran707.workers.dev

Deployed from commit 8b0b358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants