diff options
| author | yum <yum.food.vr@gmail.com> | 2025-07-23 19:05:15 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-07-23 19:05:15 -0700 |
| commit | 9bf33a4cad8196bfe7253c841ab5c35ffdbc0173 (patch) | |
| tree | 227bb536e3d8d5dd5ae63730999966cd154dd871 /ui/index.js | |
| parent | 790c91d7ad515c3c0a22ca1341316265b8f0d779 (diff) | |
add segment metadata logging feature
Segment metadata can now be logged to a json as the app runs. The goal
is to identify the params that heavily correlate with hallucinations.
Also:
* use 7zip for compression in build, speeding things up
* log dll download progress every few seconds
* shrink package
Diffstat (limited to 'ui/index.js')
| -rw-r--r-- | ui/index.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/ui/index.js b/ui/index.js index 5a5d0a6..afaaf7f 100644 --- a/ui/index.js +++ b/ui/index.js @@ -6,7 +6,12 @@ const { spawn } = require('child_process'); const https = require('https'); const { CONFIG_SCHEMA, getDefaultConfig } = require('./config-schema.js'); -const APP_ROOT = path.join(__dirname, '..'); +// Detect if we're running in development or production +const isDev = !app.isPackaged; +const APP_ROOT = isDev + ? path.join(__dirname, '..') // Development: go up from ui/ to project root + : process.resourcesPath; // Production: use Electron's resource path + const CONFIG_PATH = path.join(APP_ROOT, 'config.yaml'); let mainWindow; @@ -50,13 +55,32 @@ function createPythonEnvironment() { return env; } -// Helper function to download a file from URL +// Helper function to download a file from URL with progress function downloadFile(url, outputPath) { return new Promise((resolve, reject) => { const file = require('fs').createWriteStream(outputPath); + const fileName = path.basename(outputPath); const request = https.get(url, (response) => { if (response.statusCode === 200) { + const totalSize = parseInt(response.headers['content-length'], 10); + let downloadedSize = 0; + let lastProgressTime = Date.now(); + + response.on('data', (chunk) => { + downloadedSize += chunk.length; + + // Log progress every 5 seconds + const now = Date.now(); + if (totalSize && (now - lastProgressTime >= 5000)) { + const progress = Math.round((downloadedSize / totalSize) * 100); + const mb = (downloadedSize / 1024 / 1024).toFixed(1); + const totalMb = (totalSize / 1024 / 1024).toFixed(1); + sendPythonOutput(`Downloading ${fileName}: ${mb}/${totalMb} MB (${progress}%)`, 'info'); + lastProgressTime = now; + } + }); + response.pipe(file); file.on('finish', () => { |
