feat: add runtime startup mock flow and import reset

This commit is contained in:
OpenClaw committed 2026-03-09 15:42:25 +08:00
1 parent 36671fd8c1
commit 0a23c3813d
4 files changed
+53 -5

No files matched your search

@@ -1,10 +1,12 @@
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms))
export class NativeRuntimeAdapter {
async startSession(_appId: string): Promise<void> {
return
await sleep(600)
}
async restartSession(_appId: string): Promise<void> {
return
await sleep(400)
}
async stopSession(): Promise<void> {
+14 -3
View File
@@ -28,6 +28,14 @@ export struct ImportPage {
this.unsubscribe()
this.unsubscribe = undefined
}
this.store.reset()
}
private onBackClick(): void {
this.store.reset()
if (this.onBack) {
this.onBack()
}
}
private async onPickFile(): Promise<void> {
@@ -37,8 +45,11 @@ export struct ImportPage {
private async onImport(): Promise<void> {
await this.store.startImport()
if (this.store.phase === 'success' && this.onImportSuccess) {
this.onImportSuccess()
if (this.store.phase === 'success') {
this.store.reset()
if (this.onImportSuccess) {
this.onImportSuccess()
}
}
}
@@ -48,7 +59,7 @@ export struct ImportPage {
PageHeader({ title: '导入应用' })
if (this.onBack) {
Button('返回列表').onClick(() => {
this.onBack && this.onBack()
this.onBackClick()
}).margin({ bottom: 8, left: 16, right: 16 })
}
if (this.store.error) {
@@ -18,6 +18,8 @@ export class RuntimeSessionStore extends StoreObserver {
this.currentAppId = appId
this.phase = 'starting'
this.error = null
this.canRestart = false
this.canExit = false
this.notify()
try {
await this.service.start(appId)
@@ -35,9 +37,15 @@ export class RuntimeSessionStore extends StoreObserver {
if (!this.currentAppId) {
return
}
this.phase = 'starting'
this.error = null
this.canRestart = false
this.notify()
try {
await this.service.restart(this.currentAppId)
this.phase = 'running'
this.canRestart = true
this.canExit = true
} catch (_error) {
this.phase = 'error'
this.error = { message: '重启失败', retryable: true }