Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ const createTray = () => {
// If tray already exists, destroy it first
destroyTray();

const isDev = process.env.NODE_ENV === 'development';
const isDev = !app.isPackaged;
let iconPath: string;

if (isDev) {
Expand Down
3 changes: 1 addition & 2 deletions ui/desktop/src/utils/autoUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ export function setupAutoUpdater(tray?: Tray) {
log.info('Setting up auto-updater...');
log.info(`Current app version: ${app.getVersion()}`);
log.info(`Platform: ${process.platform}, Arch: ${process.arch}`);
log.info(`NODE_ENV: ${process.env.NODE_ENV}`);
log.info(`ENABLE_DEV_UPDATES: ${process.env.ENABLE_DEV_UPDATES}`);
log.info(`App is packaged: ${app.isPackaged}`);
log.info(`App path: ${app.getAppPath()}`);
Expand Down Expand Up @@ -470,7 +469,7 @@ function sendStatusToWindow(event: string, data?: unknown) {
function updateTrayIcon(hasUpdate: boolean) {
if (!trayRef) return;

const isDev = process.env.NODE_ENV === 'development';
const isDev = !app.isPackaged;
let iconPath: string;

if (hasUpdate) {
Expand Down
47 changes: 0 additions & 47 deletions ui/desktop/src/utils/costDatabase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Import the proper type from ConfigContext
import { getApiUrl } from '../config';
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed comment 'Import the proper type from ConfigContext' which was inaccurate since this file doesn't import anything from ConfigContext.

Copilot uses AI. Check for mistakes.
import { safeJsonParse } from './conversionUtils';

Expand Down Expand Up @@ -206,49 +205,3 @@ export async function fetchAndCachePricing(
return null;
}
}

/**
* Refresh pricing data from backend
*/
export async function refreshPricing(): Promise<boolean> {
try {
// Clear session cache to force re-fetch
sessionPricingCache.clear();

// The actual refresh happens on the backend when we call with configured_only: false
const apiUrl = getApiUrl('/config/pricing');
const secretKey = await window.electron.getSecretKey();

const headers: HeadersInit = { 'Content-Type': 'application/json' };
if (secretKey) {
headers['X-Secret-Key'] = secretKey;
}

const response = await fetch(apiUrl, {
method: 'POST',
headers,
body: JSON.stringify({ configured_only: false }),
});

return response.ok;
} catch {
return false;
}
}

// Expose functions for testing in development mode
declare global {
interface Window {
getCostForModel?: typeof getCostForModel;
fetchAndCachePricing?: typeof fetchAndCachePricing;
refreshPricing?: typeof refreshPricing;
sessionPricingCache?: typeof sessionPricingCache;
}
}

if (process.env.NODE_ENV === 'development' || typeof window !== 'undefined') {
window.getCostForModel = getCostForModel;
window.fetchAndCachePricing = fetchAndCachePricing;
window.refreshPricing = refreshPricing;
window.sessionPricingCache = sessionPricingCache;
}
16 changes: 3 additions & 13 deletions ui/desktop/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@ import log from 'electron-log';
import path from 'node:path';
import { app } from 'electron';

Comment on lines 3 to 4
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log file path uses forward slashes which will work on all platforms thanks to Node.js path normalization, but for consistency with the rest of the codebase and clarity, consider using 'path.join(app.getPath('userData'), 'logs', 'main.log')' which is already correct. However, verify that the 'logs' directory will be created automatically. If not, this could cause a runtime error when the app tries to write to a non-existent directory.

Suggested change
import { app } from 'electron';
import { app } from 'electron';
import fs from 'node:fs';
// Ensure the 'logs' directory exists
const logsDir = path.join(app.getPath('userData'), 'logs');
if (!fs.existsSync(logsDir)) {
fs.mkdirSync(logsDir, { recursive: true });
}

Copilot uses AI. Check for mistakes.
// Configure electron-log
// In development: ~/Library/Logs/goose/main.log
// In production: ~/Library/Application Support/goose/logs/main.log
log.transports.file.resolvePathFn = () => {
const isDev = process.env.NODE_ENV === 'development';
if (isDev) {
return path.join(app.getPath('home'), 'Library/Logs/goose/main.log');
}
return path.join(app.getPath('userData'), 'logs/main.log');
return path.join(app.getPath('userData'), 'logs', 'main.log');
};

// Configure log level based on environment
log.transports.file.level = process.env.NODE_ENV === 'development' ? 'debug' : 'info';

// Also log to console in development
log.transports.console.level = process.env.NODE_ENV === 'development' ? 'debug' : false;
log.transports.file.level = app.isPackaged ? 'info' : 'debug';
log.transports.console.level = app.isPackaged ? false : 'debug';

export default log;
4 changes: 1 addition & 3 deletions ui/desktop/src/utils/pathUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ const addPaths = (
executableName: string,
app: Electron.App
): void => {
const isDev = process.env.NODE_ENV === 'development';
const isPackaged = app.isPackaged;
if (isDev && !isPackaged) {
if (!app.isPackaged) {
possiblePaths.push(
path.join(process.cwd(), 'src', 'bin', executableName),
path.join(process.cwd(), 'bin', executableName),
Expand Down