Recordings were just a thin named pointer over an already-captured session's events, so the whole separate feature (recordings table, API routes, pages, UI) is gone: any completed session can now be named and replayed directly. Replaying no longer creates a session or duplicates events of its own - it just bumps the source session's playCount/lastPlayedAt. Also renames play_sessions/playSession(s) to sessions/session(s) throughout the schema, queries, API routes, and UI for consistency, and updates the README to match the new flow. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import type { ConnectedDeviceInfo, ReplayDeviceSlot } from "./types";
|
|
|
|
export interface DeviceRemapEntry {
|
|
slotLabel: string;
|
|
recordedBleName: string;
|
|
matchedDeviceIndex: number | null;
|
|
}
|
|
|
|
/**
|
|
* Best-effort name match from a session's device slots to the
|
|
* currently-connected devices. Web Bluetooth exposes no stable hardware id
|
|
* across sessions, so this is inherently approximate: two devices sharing an
|
|
* identical advertised name are indistinguishable and must be disambiguated
|
|
* manually in the remap UI - this isn't a bug, it's a hard BLE limitation.
|
|
*/
|
|
export function autoMapDeviceSlots(
|
|
slots: ReplayDeviceSlot[],
|
|
connectedDevices: ConnectedDeviceInfo[],
|
|
): DeviceRemapEntry[] {
|
|
const usedIndexes = new Set<number>();
|
|
|
|
return slots.map((slot) => {
|
|
const normalizedSlotName = slot.recordedBleName.trim().toLowerCase();
|
|
|
|
const exact = connectedDevices.find(
|
|
(d) => !usedIndexes.has(d.index) && d.name.trim().toLowerCase() === normalizedSlotName,
|
|
);
|
|
const partial =
|
|
exact ??
|
|
connectedDevices.find(
|
|
(d) =>
|
|
!usedIndexes.has(d.index) &&
|
|
(d.name.toLowerCase().includes(normalizedSlotName) ||
|
|
normalizedSlotName.includes(d.name.toLowerCase())),
|
|
);
|
|
|
|
if (partial) usedIndexes.add(partial.index);
|
|
|
|
return {
|
|
slotLabel: slot.slotLabel,
|
|
recordedBleName: slot.recordedBleName,
|
|
matchedDeviceIndex: partial?.index ?? null,
|
|
};
|
|
});
|
|
}
|