惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
H
Hackread – Cybersecurity News, Data Breaches, AI and More
WordPress大学
WordPress大学
B
Blog RSS Feed
A
About on SuperTechFans
V
Visual Studio Blog
J
Java Code Geeks
U
Unit 42
人人都是产品经理
人人都是产品经理
Martin Fowler
Martin Fowler
Recent Announcements
Recent Announcements
M
MIT News - Artificial intelligence
IT之家
IT之家
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
C
Check Point Blog
博客园 - 叶小钗
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
B
Blog
S
SegmentFault 最新的问题
Microsoft Azure Blog
Microsoft Azure Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
perf: avoid redundant device pairing writes · openclaw/op...
steipete · 2026-04-24 · via Recent Commits to openclaw:main

@@ -154,8 +154,22 @@ async function loadState(baseDir?: string): Promise<DevicePairingStateFile> {

154154

return state;

155155

}

156156157-

async function persistState(state: DevicePairingStateFile, baseDir?: string) {

157+

type DevicePairingPersistTarget = "pending" | "paired" | "both";

158+159+

async function persistState(

160+

state: DevicePairingStateFile,

161+

baseDir: string | undefined,

162+

target: DevicePairingPersistTarget,

163+

) {

158164

const { pendingPath, pairedPath } = resolvePairingPaths(baseDir, "devices");

165+

if (target === "pending") {

166+

await writeJsonAtomic(pendingPath, state.pendingById);

167+

return;

168+

}

169+

if (target === "paired") {

170+

await writeJsonAtomic(pairedPath, state.pairedByDeviceId);

171+

return;

172+

}

159173

await Promise.all([

160174

writeJsonAtomic(pendingPath, state.pendingById),

161175

writeJsonAtomic(pairedPath, state.pairedByDeviceId),

@@ -526,7 +540,7 @@ export async function requestDevicePairing(

526540

},

527541

});

528542

},

529-

persist: async () => await persistState(state, baseDir),

543+

persist: async () => await persistState(state, baseDir, "pending"),

530544

});

531545

});

532546

}

@@ -636,7 +650,7 @@ export async function approveDevicePairing(

636650

};

637651

delete state.pendingById[requestId];

638652

state.pairedByDeviceId[device.deviceId] = device;

639-

await persistState(state, baseDir);

653+

await persistState(state, baseDir, "both");

640654

return { status: "approved", requestId, device };

641655

});

642656

}

@@ -723,7 +737,7 @@ export async function approveBootstrapDevicePairing(

723737

};

724738

delete state.pendingById[requestId];

725739

state.pairedByDeviceId[device.deviceId] = device;

726-

await persistState(state, baseDir);

740+

await persistState(state, baseDir, "both");

727741

return { status: "approved", requestId, device };

728742

});

729743

}

@@ -741,7 +755,7 @@ export async function rejectDevicePairing(

741755

requestId,

742756

idKey: "deviceId",

743757

loadState: () => loadState(baseDir),

744-

persistState: (state) => persistState(state, baseDir),

758+

persistState: (state) => persistState(state, baseDir, "pending"),

745759

getId: (pending: DevicePairingPendingRequest) => pending.deviceId,

746760

});

747761

});

@@ -763,7 +777,7 @@ export async function removePairedDevice(

763777

delete state.pendingById[requestId];

764778

}

765779

}

766-

await persistState(state, baseDir);

780+

await persistState(state, baseDir, "both");

767781

return { deviceId: normalized };

768782

});

769783

}

@@ -794,7 +808,7 @@ export async function updatePairedDeviceMetadata(

794808

next.remoteIp = patch.remoteIp;

795809

}

796810

state.pairedByDeviceId[normalizedDeviceId] = next;

797-

await persistState(state, baseDir);

811+

await persistState(state, baseDir, "paired");

798812

});

799813

}

800814

@@ -862,7 +876,7 @@ export async function verifyDeviceToken(params: {

862876

device.tokens ??= {};

863877

device.tokens[role] = entry;

864878

state.pairedByDeviceId[device.deviceId] = device;

865-

await persistState(state, params.baseDir);

879+

await persistState(state, params.baseDir, "paired");

866880

return { ok: true };

867881

});

868882

}

@@ -919,7 +933,7 @@ export async function ensureDeviceToken(params: {

919933

tokens[role] = next;

920934

device.tokens = tokens;

921935

state.pairedByDeviceId[device.deviceId] = device;

922-

await persistState(state, params.baseDir);

936+

await persistState(state, params.baseDir, "paired");

923937

return next;

924938

});

925939

}

@@ -996,7 +1010,7 @@ export async function rotateDeviceToken(params: {

9961010

tokens[role] = next;

9971011

device.tokens = tokens;

9981012

state.pairedByDeviceId[device.deviceId] = device;

999-

await persistState(state, params.baseDir);

1013+

await persistState(state, params.baseDir, "paired");

10001014

return { ok: true, entry: next };

10011015

});

10021016

}

@@ -1024,7 +1038,7 @@ export async function revokeDeviceToken(params: {

10241038

tokens[role] = entry;

10251039

device.tokens = tokens;

10261040

state.pairedByDeviceId[device.deviceId] = device;

1027-

await persistState(state, params.baseDir);

1041+

await persistState(state, params.baseDir, "paired");

10281042

return entry;

10291043

});

10301044

}

@@ -1037,7 +1051,7 @@ export async function clearDevicePairing(deviceId: string, baseDir?: string): Pr

10371051

return false;

10381052

}

10391053

delete state.pairedByDeviceId[normalizedId];

1040-

await persistState(state, baseDir);

1054+

await persistState(state, baseDir, "paired");

10411055

return true;

10421056

});

10431057

}