refactor(webui): centralize native runtime access (#4769)

This commit is contained in:
chengyongru
2026-07-14 15:00:30 +08:00
committed by GitHub
parent b7048cf76a
commit 6c9e3a2cc3
5 changed files with 95 additions and 33 deletions
+3 -4
View File
@@ -57,7 +57,6 @@ import {
} from "@/lib/api";
import {
createRuntimeHost,
getHostApi,
toRuntimeSurface,
} from "@/lib/runtime";
import { projectNameFromPath } from "@/lib/workspace";
@@ -939,8 +938,8 @@ export default function App() {
};
const handleNativeEngineRestart = async (): Promise<string> => {
const hostApi = getHostApi();
if (!hostApi?.restartEngine) {
const runtimeHost = createRuntimeHost(state.runtimeSurface);
if (!runtimeHost.restartEngine) {
throw new Error("native engine restart is unavailable");
}
rememberRestartRoute();
@@ -950,7 +949,7 @@ export default function App() {
// ignore storage errors
}
try {
await hostApi.restartEngine();
await runtimeHost.restartEngine();
const refreshed = await refreshReadyClient(state.client, state.runtimeSurface);
return refreshed.token;
} finally {