Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(data-sync): create missing device id before upload

Ezra Elletted7d6fd24695b
diff --git a/apps/screenpipe-app-tauri/components/settings/account-section.tsx b/apps/screenpipe-app-tauri/components/settings/account-section.tsx
index d6585ef26..b59eebe28 100644
--- a/apps/screenpipe-app-tauri/components/settings/account-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/account-section.tsx
@@ -192,6 +192,11 @@ export function AccountSection() {
if (checked && !accountId) {
throw new Error("sign in again to enable data sync on this device");
}
+ let deviceId = settings.deviceId;
+ if (!deviceId) {
+ deviceId = crypto.randomUUID();
+ await updateSettings({ deviceId });
+ }
const deviceName = checked
? settings.dataSyncDeviceName?.trim() ||
@@ -221,7 +226,7 @@ export function AccountSection() {
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
- "X-Screenpipe-Device-Id": settings.deviceId,
+ "X-Screenpipe-Device-Id": deviceId,
"X-Screenpipe-Device-Label": deviceName,
},
body: JSON.stringify({ enabled: checked }),
@@ -235,7 +240,7 @@ export function AccountSection() {
await updateSettings({
dataSyncEnabled: checked,
dataSyncDeviceName: deviceName,
- dataSyncAccountId: checked ? accountId : "",
+ dataSyncAccountId: checked ? accountId! : "",
...(checked ? { dataSyncEnabledAt: new Date().toISOString() } : {}),
});
} catch (error) {