diff --git a/apps/companion/main/di-container.ts b/apps/companion/main/di-container.ts index 12939162d..ebb550209 100644 --- a/apps/companion/main/di-container.ts +++ b/apps/companion/main/di-container.ts @@ -1,3 +1,5 @@ +import { app } from 'electron'; +import * as path from 'path'; import { InMemorySessionRepository } from '@/packages/infrastructure/repositories/InMemorySessionRepository'; import { MockBrowserAutomationAdapter } from '@/packages/infrastructure/adapters/automation/MockBrowserAutomationAdapter'; import { BrowserDevToolsAdapter } from '@/packages/infrastructure/adapters/automation/BrowserDevToolsAdapter'; @@ -165,6 +167,24 @@ export class DIContainer { return this.permissionService; } + /** + * Resolve the fixtures path relative to the monorepo root. + * In Electron, app.getAppPath() returns the path to the app's main directory + * (e.g., apps/companion/dist/main in development, or the asar in production). + * We navigate up to find the monorepo root and then join with the resources path. + */ + private resolveFixturesPath(configuredPath: string): string { + if (path.isAbsolute(configuredPath)) { + return configuredPath; + } + + const appPath = app.getAppPath(); + const projectRoot = path.resolve(appPath, '../../../'); + const resolvedPath = path.join(projectRoot, configuredPath); + + return resolvedPath; + } + /** * Initialize fixture server for development mode. * Starts an embedded HTTP server serving static HTML fixtures. @@ -185,7 +205,13 @@ export class DIContainer { this.fixtureServer = new FixtureServerService(); const port = config.fixtureServer.port; - const fixturesPath = config.fixtureServer.fixturesPath; + const fixturesPath = this.resolveFixturesPath(config.fixtureServer.fixturesPath); + + this.logger.debug('Fixture server path resolution', { + configuredPath: config.fixtureServer.fixturesPath, + appPath: app.getAppPath(), + resolvedPath: fixturesPath + }); try { await this.fixtureServer.start(port, fixturesPath);