-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdebug-check-sync.ts
More file actions
69 lines (57 loc) · 1.95 KB
/
debug-check-sync.ts
File metadata and controls
69 lines (57 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { connectToSuperhuman, disconnect } from "./src/superhuman-api";
async function checkSync() {
console.log("=== Checking Draft Sync Status ===\n");
const conn = await connectToSuperhuman(9333, true);
if (!conn) {
console.error("Failed to connect");
return;
}
// Look for the draft in the actual message store
const result = await conn.Runtime.evaluate({
expression: `
(async () => {
try {
// First, get the draft from compose controller
const cfc = window.ViewState?._composeFormController;
if (!cfc) return { error: "No cfc" };
const draftKey = Object.keys(cfc).find(k => k.startsWith('draft'));
if (!draftKey) return { error: "No draft key" };
const ctrl = cfc[draftKey];
const draft = ctrl?.state?.draft;
// Check the draft object structure
const draftInfo = {
id: draft?.id,
subject: draft?.subject,
body: draft?.body?.substring(0, 100),
to: (draft?.to || []).map(r => r.email),
from: draft?.from?.email,
dirty: draft?.dirty,
isSaving: draft?.isSaving,
savedAt: draft?.savedAt,
messageId: draft?.messageId,
threadId: draft?.threadId,
hasAllProps: Object.keys(draft || {})
};
// Try to see if saveDraftAsync was called and completed
const controllerState = {
isSaving: ctrl?.isSaving,
lastSaveError: ctrl?.lastSaveError,
};
return {
draftKey,
draftInfo,
controllerState
};
} catch (e) {
return { error: e.message, stack: e.stack };
}
})()
`,
returnByValue: true,
awaitPromise: true
});
console.log("Draft and sync state:");
console.log(JSON.stringify(result.result.value, null, 2));
await disconnect(conn);
}
checkSync().catch(console.error);