|
1 | | -; Custom NSIS uninstall hook — asks the user whether to keep downloaded |
2 | | -; Whisper models. If they choose No, models are copied to %APPDATA%\Echo\ |
3 | | -; models-preserved\ before the installation directory is wiped; the app |
4 | | -; restores them to the install dir on next launch. |
| 1 | +; Custom install + uninstall UI for Echo. |
| 2 | +; |
| 3 | +; Install: user picks which Whisper model the app should download on first |
| 4 | +; launch. The choice is written to %APPDATA%\Echo\install-choice.json and |
| 5 | +; consumed + deleted by the app on its first boot. |
| 6 | +; |
| 7 | +; Uninstall: user chooses whether to also wipe %APPDATA%\Echo\ (downloaded |
| 8 | +; whisper.cpp binary + models + saved settings) or keep it in place for a |
| 9 | +; future reinstall. |
5 | 10 |
|
6 | | -!macro customUnInstall |
7 | | - ; Only prompt if there's at least one .bin model on disk |
8 | | - IfFileExists "$INSTDIR\resources\app.asar.unpacked\node_modules\nodejs-whisper\cpp\whisper.cpp\models\ggml-*.bin" 0 skip_model_prompt |
| 11 | +!include "nsDialogs.nsh" |
| 12 | +!include "LogicLib.nsh" |
| 13 | + |
| 14 | +; ─── Install-time model-choice page ───────────────────────────────────────── |
| 15 | + |
| 16 | +Var ModelChoice |
| 17 | +Var MC_Dialog |
| 18 | +Var MC_RbTiny |
| 19 | +Var MC_RbBase |
| 20 | +Var MC_RbSmall |
| 21 | +Var MC_RbMedium |
| 22 | +Var MC_RbLargeTurbo |
| 23 | + |
| 24 | +Function ModelChoicePage |
| 25 | + !insertmacro MUI_HEADER_TEXT "Choose a Whisper model" "Echo downloads this model the first time it runs. You can switch or download others later from Settings." |
| 26 | + nsDialogs::Create 1018 |
| 27 | + Pop $MC_Dialog |
| 28 | + ${If} $MC_Dialog == error |
| 29 | + Abort |
| 30 | + ${EndIf} |
| 31 | + |
| 32 | + ${NSD_CreateRadioButton} 0 0u 100% 12u "Tiny – 75 MB (fastest)" |
| 33 | + Pop $MC_RbTiny |
| 34 | + ${NSD_CreateRadioButton} 0 15u 100% 12u "Base – 142 MB (recommended)" |
| 35 | + Pop $MC_RbBase |
| 36 | + ${NSD_CreateRadioButton} 0 30u 100% 12u "Small – 488 MB (better accuracy)" |
| 37 | + Pop $MC_RbSmall |
| 38 | + ${NSD_CreateRadioButton} 0 45u 100% 12u "Medium – 1.5 GB (great accuracy)" |
| 39 | + Pop $MC_RbMedium |
| 40 | + ${NSD_CreateRadioButton} 0 60u 100% 12u "Large v3 Turbo – 1.6 GB (best accuracy)" |
| 41 | + Pop $MC_RbLargeTurbo |
| 42 | + |
| 43 | + ${NSD_Check} $MC_RbBase |
| 44 | + |
| 45 | + nsDialogs::Show |
| 46 | +FunctionEnd |
9 | 47 |
|
| 48 | +Function ModelChoicePageLeave |
| 49 | + ${NSD_GetState} $MC_RbTiny $0 |
| 50 | + ${If} $0 == ${BST_CHECKED} |
| 51 | + StrCpy $ModelChoice "tiny" |
| 52 | + Return |
| 53 | + ${EndIf} |
| 54 | + ${NSD_GetState} $MC_RbSmall $0 |
| 55 | + ${If} $0 == ${BST_CHECKED} |
| 56 | + StrCpy $ModelChoice "small" |
| 57 | + Return |
| 58 | + ${EndIf} |
| 59 | + ${NSD_GetState} $MC_RbMedium $0 |
| 60 | + ${If} $0 == ${BST_CHECKED} |
| 61 | + StrCpy $ModelChoice "medium" |
| 62 | + Return |
| 63 | + ${EndIf} |
| 64 | + ${NSD_GetState} $MC_RbLargeTurbo $0 |
| 65 | + ${If} $0 == ${BST_CHECKED} |
| 66 | + StrCpy $ModelChoice "large-v3-turbo" |
| 67 | + Return |
| 68 | + ${EndIf} |
| 69 | + ; Anything else → base |
| 70 | + StrCpy $ModelChoice "base" |
| 71 | +FunctionEnd |
| 72 | + |
| 73 | +!macro customPageAfterChangeDir |
| 74 | + Page custom ModelChoicePage ModelChoicePageLeave |
| 75 | +!macroend |
| 76 | + |
| 77 | +!macro customInstall |
| 78 | + CreateDirectory "$APPDATA\Echo" |
| 79 | + FileOpen $0 "$APPDATA\Echo\install-choice.json" w |
| 80 | + FileWrite $0 '{"initialModelSize":"$ModelChoice"}' |
| 81 | + FileClose $0 |
| 82 | +!macroend |
| 83 | + |
| 84 | +; ─── Uninstall prompt ─────────────────────────────────────────────────────── |
| 85 | + |
| 86 | +!macro customUnInstall |
| 87 | + ; Default to "No" — keep models/settings unless the user explicitly opts in |
| 88 | + ; to wiping them. |
10 | 89 | MessageBox MB_YESNO|MB_ICONQUESTION \ |
11 | | - "Remove downloaded Whisper models as well?$\r$\n$\r$\n\ |
12 | | -Choose No to keep them — they'll be restored automatically the next time you install Echo." \ |
13 | | - /SD IDYES \ |
14 | | - IDYES skip_model_prompt |
15 | | - |
16 | | - ; User chose No — preserve the models outside the install dir |
17 | | - CreateDirectory "$APPDATA\Echo\models-preserved" |
18 | | - CopyFiles /SILENT \ |
19 | | - "$INSTDIR\resources\app.asar.unpacked\node_modules\nodejs-whisper\cpp\whisper.cpp\models\*.bin" \ |
20 | | - "$APPDATA\Echo\models-preserved\" |
21 | | - |
22 | | - skip_model_prompt: |
| 90 | + "Also delete Echo's downloaded models and saved settings?$\r$\n$\r$\n\ |
| 91 | +Choose No to keep them for a future reinstall." \ |
| 92 | + /SD IDNO \ |
| 93 | + IDNO skip_appdata_wipe |
| 94 | + RMDir /r "$APPDATA\Echo" |
| 95 | + skip_appdata_wipe: |
23 | 96 | !macroend |
0 commit comments