better tui

This commit is contained in:
Nick Sweeting
2026-01-19 01:53:32 -08:00
parent 1cb2d5070e
commit b5bbc3b549
9 changed files with 690 additions and 109 deletions

View File

@@ -384,6 +384,8 @@ async function launchChromium(options = {}) {
return { success: false, error: 'Chrome binary not found' };
}
const downloadsDir = getEnv('CHROME_DOWNLOADS_DIR');
// Kill zombies first
if (killZombies) {
killZombieChrome();
@@ -412,6 +414,28 @@ async function launchChromium(options = {}) {
console.error(`[!] Failed to remove SingletonLock: ${e.message}`);
}
}
if (downloadsDir) {
try {
const defaultProfileDir = path.join(userDataDir, 'Default');
const prefsPath = path.join(defaultProfileDir, 'Preferences');
fs.mkdirSync(defaultProfileDir, { recursive: true });
let prefs = {};
if (fs.existsSync(prefsPath)) {
try {
prefs = JSON.parse(fs.readFileSync(prefsPath, 'utf-8'));
} catch (e) {
prefs = {};
}
}
prefs.download = prefs.download || {};
prefs.download.default_directory = downloadsDir;
prefs.download.prompt_for_download = false;
fs.writeFileSync(prefsPath, JSON.stringify(prefs));
console.error(`[*] Set Chrome download directory: ${downloadsDir}`);
} catch (e) {
console.error(`[!] Failed to set Chrome download directory: ${e.message}`);
}
}
}
// Find a free port
@@ -455,6 +479,11 @@ async function launchChromium(options = {}) {
// Dynamic args come after base so they can override if needed
const chromiumArgs = [...baseArgs, ...dynamicArgs, ...extraArgs];
// Ensure keychain prompts are disabled on macOS
if (!chromiumArgs.includes('--use-mock-keychain')) {
chromiumArgs.push('--use-mock-keychain');
}
// Add extension loading flags
if (extensionPaths.length > 0) {
const extPathsArg = extensionPaths.join(',');