02-desktop-device-type.md
Change 2 — Add "desktop" DeviceType
DRAFT. Conforms to
_GROUND-TRUTH.md.
VERDICT: already done. This change is a NO-OP against current source.
The brief assumed "desktop" was missing from DeviceType and that the type
"likely" lives in src/shared/types.ts. Both assumptions are wrong against the
ground-truth source:
-
DeviceTypeis defined insrc/shared/sync-types.ts:11, nottypes.ts(types.tshas noDeviceTypesymbol).chirp-handshake.ts:29andpaired-devices.ts:23both import device types from./sync-types. -
"desktop"is already a member:// src/shared/sync-types.ts:11 export type DeviceType = "extension" | "android" | "ios" | "desktop"; -
The full desktop plumbing already exists:
DEVICE_TYPE_DESKTOP = 0x04chirp byte tag (sync-types.ts:19)DeviceTypeByteincludes it (sync-types.ts:25)deviceTypeFromByte(0x04) → "desktop"(sync-types.ts:36)deviceTypeToByte("desktop") → 0x04(sync-types.ts:45)chirp-payload.tsaccepts byte0x04on the wire (chirp-payload.ts:5,89)
-
peach-sync announces exactly this string:
.device_type = "desktop"(peach-sync/src/pairing.zig:177), which lands on the existing union member.
No edit to the type union is required. If a downstream pass "adds" it again it will be a redundant no-op.
What ACTUALLY needs verifying: the storage gate (paired-devices.ts)
The real question is whether the paired-device registry rejects a "desktop"
device. It does not — there is no enum gate.
upsertPairedDevice (src/background/paired-devices.ts:56-70) validates only
presence, never membership against the DeviceType union:
// paired-devices.ts:60
if (!device.deviceType) throw new Error("device.deviceType is required");
It checks the field is truthy, not that it equals a known literal. "desktop"
(or any non-empty string) passes. Storage round-trips it verbatim
(isPairedDevice, paired-devices.ts:174-180, only checks deviceId is a
non-empty string and pairedAt is a number — deviceType is not gated).
PairedDevice.deviceType is DeviceType | undefined (sync-types.ts:89), so
"desktop" is statically valid; nothing to extend.
Conclusion / action for implementer
- No code change for Change 2. Optionally, add a regression test asserting a
"desktop"device upserts and round-trips throughpaired-devices.ts(kept minimal; the registry already supports it). - If the brief's reviewer insists on a literal "edit", the only honest one is a doc/comment — there is no missing union member and no gate to widen.
Discrepancy summary (for the report)
- Brief said: add
"desktop"toDeviceTypeinsrc/shared/types.ts. - Source truth:
"desktop"already present insrc/shared/sync-types.ts:11;types.tsis the wrong file; the storage layer already accepts it. Change is unnecessary.