restoreInstallIfReady method

Future<bool> restoreInstallIfReady({
  1. required SyniPersona persona,
  2. required SyniModelSpec model,
})

Cold-start restore: if the model + tokenizer are already on disk for model, bind persona and load the engine — no download. Otherwise leaves state as SyniNotInstalled and returns false.

Idempotent. Safe to call from initState. Use this so the screen doesn't show the Install card with a download warning when the user has installed before.

Implementation

Future<bool> restoreInstallIfReady({
  required SyniPersona persona,
  required SyniModelSpec model,
}) async {
  if (currentState is SyniInstalled || currentState is SyniInstalling) {
    return isInstalled;
  }
  if (!await _installer.isModelOnDisk(model)) return false;
  // Files present — install() will skip the download (file exists check)
  // and go straight to engine load.
  try {
    await install(persona: persona, model: model);
  } catch (_) {
    // Failure already emitted SyniInstallFailed; the screen handles it.
  }
  return isInstalled;
}