fix(md): clawx md injection error (#193)

This commit is contained in:
Haze
2026-02-26 18:53:53 +08:00
committed by GitHub
Unverified
parent 7929a43601
commit 0be07eab2a
4 changed files with 63 additions and 31 deletions

View File

@@ -197,12 +197,22 @@ async function initialize(): Promise<void> {
mainWindow?.webContents.send('gateway:error', String(error));
}
// Merge ClawX context snippets into the (now fully-seeded) bootstrap files
try {
ensureClawXContext();
} catch (error) {
// Merge ClawX context snippets into the workspace bootstrap files.
// The gateway seeds workspace files asynchronously after its HTTP server
// is ready, so ensureClawXContext will retry until the target files appear.
void ensureClawXContext().catch((error) => {
logger.warn('Failed to merge ClawX context into workspace:', error);
}
});
// Re-apply ClawX context after every gateway restart because the gateway
// may re-seed workspace files with clean templates (losing ClawX markers).
gatewayManager.on('status', (status: { state: string }) => {
if (status.state === 'running') {
void ensureClawXContext().catch((error) => {
logger.warn('Failed to re-merge ClawX context after gateway reconnect:', error);
});
}
});
}
// Application lifecycle