feat(sandbox): cache the guest image at startup instead of on first command

Pull the configured guest image in the background when the Manager boots and
when sandbox enforcement is switched on, so a sandboxed command no longer
pays the multi-gigabyte download. msb pull is a no-op once cached, startup is
never blocked by it, and a command racing the pull joins the same in-flight
boot.
This commit is contained in:
Chris Scott committed 2026-08-28 13:05:56 -04:00
1 parent 5beb3432d4
commit 2eba81d524
8 files changed
+82 -12

No files matched your search

@@ -414,6 +414,11 @@ class OpenCodeServerManager {
this.failNonRecoverable(`Failed to stop the workspace sandbox while disabling enforcement: ${error instanceof Error ? error.message : String(error)}`)
}
}
if (sandboxEnforced && !this.sandboxEnforced) {
void new SandboxRuntimeService(this.db).prepareWorkspaceSandboxOnBoot().catch((error) => {
logger.warn('Sandbox enforcement enabled but preparing the guest image failed:', error)
})
}
logger.info(`OpenCode sandbox enforcement: ${sandboxEnforced ? 'enabled' : 'disabled'}`)
}