@@ -39,7 +39,6 @@ import { downloadDir, homeDir } from "@tauri-apps/api/path";
3939import {
4040 engineDoctor ,
4141 engineInfo ,
42- opencodeDbMigrate ,
4342 engineInstall ,
4443 engineStart ,
4544 engineStop ,
@@ -103,11 +102,6 @@ export type SandboxCreateProgressState = {
103102
104103export type SandboxCreatePhase = "idle" | "preflight" | "provisioning" | "finalizing" ;
105104
106- export type MigrationRepairResult = {
107- ok : boolean ;
108- message : string ;
109- } ;
110-
111105type RuntimeWorkspaceLookup = {
112106 workspaceId ?: string | null ;
113107 directoryHint ?: string | null ;
@@ -211,13 +205,6 @@ export function createWorkspaceStore(options: {
211205 const LONG_BOOT_CONNECT_REASONS = new Set ( [ "host-start" , "bootstrap-local" ] ) ;
212206 const DEFAULT_WORKSPACE_HOME_FOLDER_NAME = "OpenWork" ;
213207 const FIRST_RUN_WELCOME_WORKSPACE_NAME = "Welcome" ;
214- const DB_MIGRATE_UNSUPPORTED_PATTERNS = [
215- / u n k n o w n (?: \s + s u b ) ? c o m m a n d \s + [ ' " ` ] ? d b [ ' " ` ] ? / i,
216- / u n r e c o g n i z e d (?: \s + s u b ) ? c o m m a n d \s + [ ' " ` ] ? d b [ ' " ` ] ? / i,
217- / n o s u c h c o m m a n d [: \s] + d b / i,
218- / f o u n d a r g u m e n t [ ' " ` ] d b [ ' " ` ] w h i c h w a s n ' t e x p e c t e d / i,
219- ] as const ;
220-
221208 const preferredInitialSessionTitleForPreset = ( preset : WorkspacePreset ) => {
222209 const trimmed = defaultBlueprintSessionsForPreset ( preset )
223210 . find ( ( session ) => session . openOnFirstLoad === true ) ?. title ?. trim ( ) ;
@@ -269,18 +256,6 @@ export function createWorkspaceStore(options: {
269256 return DEFAULT_CONNECT_HEALTH_TIMEOUT_MS ;
270257 } ;
271258
272- const formatExecOutput = ( result : { stdout : string ; stderr : string } ) => {
273- const stderr = result . stderr . trim ( ) ;
274- const stdout = result . stdout . trim ( ) ;
275- return [ stderr , stdout ] . filter ( Boolean ) . join ( "\n\n" ) ;
276- } ;
277-
278- const isDbMigrateUnsupported = ( output : string ) => {
279- const normalized = output . trim ( ) ;
280- if ( ! normalized ) return false ;
281- return DB_MIGRATE_UNSUPPORTED_PATTERNS . some ( ( pattern ) => pattern . test ( normalized ) ) ;
282- } ;
283-
284259 const [ engine , setEngine ] = createSignal < EngineInfo | null > ( null ) ;
285260 const [ engineAuth , setEngineAuth ] = createSignal < OpencodeAuth | null > ( null ) ;
286261 const [ engineDoctorResult , setEngineDoctorResult ] = createSignal < EngineDoctorResult | null > ( null ) ;
@@ -402,9 +377,6 @@ export function createWorkspaceStore(options: {
402377 > ( { } ) ;
403378 const [ exportingWorkspaceConfig , setExportingWorkspaceConfig ] = createSignal ( false ) ;
404379 const [ importingWorkspaceConfig , setImportingWorkspaceConfig ] = createSignal ( false ) ;
405- const [ migrationRepairBusy , setMigrationRepairBusy ] = createSignal ( false ) ;
406- const [ migrationRepairResult , setMigrationRepairResult ] = createSignal < MigrationRepairResult | null > ( null ) ;
407-
408380 const selectedWorkspaceInfo = createMemo ( ( ) => workspaces ( ) . find ( ( w ) => w . id === selectedWorkspaceId ( ) ) ?? null ) ;
409381 const connectedWorkspaceInfo = createMemo ( ( ) => {
410382 const id = connectedWorkspaceId ( ) ?. trim ( ) ?? "" ;
@@ -3175,109 +3147,6 @@ export function createWorkspaceStore(options: {
31753147 }
31763148 }
31773149
3178- function canRepairOpencodeMigration ( ) {
3179- if ( ! isTauriRuntime ( ) ) return false ;
3180- const workspace = selectedWorkspaceInfo ( ) ;
3181- if ( ! workspace || workspace . workspaceType !== "local" ) return false ;
3182- return Boolean ( selectedWorkspacePath ( ) . trim ( ) ) ;
3183- }
3184-
3185- async function repairOpencodeMigration ( optionsOverride ?: { navigate ?: boolean } ) {
3186- if ( ! isTauriRuntime ( ) ) {
3187- const message = t ( "app.migration.desktop_required" , currentLocale ( ) ) ;
3188- setMigrationRepairResult ( { ok : false , message } ) ;
3189- options . setError ( message ) ;
3190- return false ;
3191- }
3192-
3193- if ( migrationRepairBusy ( ) ) return false ;
3194-
3195- const workspace = selectedWorkspaceInfo ( ) ;
3196- if ( ! workspace || workspace . workspaceType !== "local" ) {
3197- const message = t ( "app.migration.local_only" , currentLocale ( ) ) ;
3198- setMigrationRepairResult ( { ok : false , message } ) ;
3199- options . setError ( message ) ;
3200- return false ;
3201- }
3202-
3203- const root = selectedWorkspacePath ( ) . trim ( ) ;
3204- if ( ! root ) {
3205- const message = t ( "app.migration.workspace_required" , currentLocale ( ) ) ;
3206- setMigrationRepairResult ( { ok : false , message } ) ;
3207- options . setError ( message ) ;
3208- return false ;
3209- }
3210-
3211- setMigrationRepairBusy ( true ) ;
3212- setMigrationRepairResult ( null ) ;
3213- options . setError ( null ) ;
3214- options . setBusy ( true ) ;
3215- options . setBusyLabel ( "status.repairing_migration" ) ;
3216- options . setBusyStartedAt ( Date . now ( ) ) ;
3217-
3218- try {
3219- if ( engine ( ) ?. running ) {
3220- const info = await engineStop ( ) ;
3221- setEngine ( info ) ;
3222- }
3223-
3224- const source = options . engineSource ( ) ;
3225- const result = await opencodeDbMigrate ( {
3226- projectDir : root ,
3227- preferSidecar : source === "sidecar" ,
3228- opencodeBinPath : source === "custom" ? options . engineCustomBinPath ?.( ) . trim ( ) || null : null ,
3229- } ) ;
3230-
3231- if ( ! result . ok ) {
3232- const output = formatExecOutput ( result ) ;
3233- if ( isDbMigrateUnsupported ( output ) ) {
3234- const message = t ( "app.migration.unsupported" , currentLocale ( ) ) ;
3235- setMigrationRepairResult ( { ok : false , message } ) ;
3236- options . setError ( message ) ;
3237- return false ;
3238- }
3239-
3240- const fallback = t ( "app.migration.failed" , currentLocale ( ) ) ;
3241- const message = output ? `${ fallback } \n\n${ output } ` : fallback ;
3242- setMigrationRepairResult ( { ok : false , message } ) ;
3243- options . setError ( addOpencodeCacheHint ( message ) ) ;
3244- return false ;
3245- }
3246-
3247- const started = await startHost ( {
3248- workspacePath : root ,
3249- navigate : optionsOverride ?. navigate ?? false ,
3250- } ) ;
3251- if ( ! started ) {
3252- const message = t ( "app.migration.restart_failed" , currentLocale ( ) ) ;
3253- setMigrationRepairResult ( { ok : false , message } ) ;
3254- return false ;
3255- }
3256-
3257- setMigrationRepairResult ( { ok : true , message : t ( "app.migration.success" , currentLocale ( ) ) } ) ;
3258- return true ;
3259- } catch ( error ) {
3260- const message = addOpencodeCacheHint ( error instanceof Error ? error . message : safeStringify ( error ) ) ;
3261- setMigrationRepairResult ( { ok : false , message } ) ;
3262- options . setError ( message ) ;
3263- return false ;
3264- } finally {
3265- setMigrationRepairBusy ( false ) ;
3266- options . setBusy ( false ) ;
3267- options . setBusyLabel ( null ) ;
3268- options . setBusyStartedAt ( null ) ;
3269- }
3270- }
3271-
3272- async function onRepairOpencodeMigration ( ) {
3273- options . setStartupPreference ( "local" ) ;
3274- options . setOnboardingStep ( "connecting" ) ;
3275- const ok = await repairOpencodeMigration ( { navigate : true } ) ;
3276- if ( ! ok ) {
3277- options . setOnboardingStep ( "local" ) ;
3278- }
3279- }
3280-
32813150 async function startHost ( optionsOverride ?: { workspacePath ?: string ; navigate ?: boolean } ) {
32823151 if ( ! isTauriRuntime ( ) ) {
32833152 options . setError ( t ( "app.error.tauri_required" , currentLocale ( ) ) ) ;
@@ -3329,7 +3198,6 @@ export function createWorkspaceStore(options: {
33293198 }
33303199
33313200 options . setError ( null ) ;
3332- setMigrationRepairResult ( null ) ;
33333201 options . setBusy ( true ) ;
33343202 options . setBusyLabel ( "status.starting_engine" ) ;
33353203 options . setBusyStartedAt ( Date . now ( ) ) ;
@@ -3989,8 +3857,6 @@ export function createWorkspaceStore(options: {
39893857 workspaceConnectionStateById,
39903858 exportingWorkspaceConfig,
39913859 importingWorkspaceConfig,
3992- migrationRepairBusy,
3993- migrationRepairResult,
39943860 selectedWorkspaceInfo,
39953861 selectedWorkspaceDisplay,
39963862 selectedWorkspacePath,
@@ -4024,8 +3890,6 @@ export function createWorkspaceStore(options: {
40243890 pickWorkspaceFolder,
40253891 exportWorkspaceConfig,
40263892 importWorkspaceConfig,
4027- canRepairOpencodeMigration,
4028- repairOpencodeMigration,
40293893 startHost,
40303894 stopHost,
40313895 reloadWorkspaceEngine,
@@ -4034,7 +3898,6 @@ export function createWorkspaceStore(options: {
40343898 onSelectStartup,
40353899 onBackToWelcome,
40363900 onStartHost,
4037- onRepairOpencodeMigration,
40383901 onAttachHost,
40393902 onConnectClient,
40403903 onRememberStartupToggle,
0 commit comments