[AI] Fix navigator is not defined error in @actual-app/api for Node.js environments (#7202)

* [AI] Fix navigator is not defined error in @actual-app/api for Node.js environments

Add platform.api.ts to provide Node.js-safe defaults for platform detection,
which the API's Vite config resolves before the browser-only platform.ts.
Also guard navigator access in environment.ts isElectron() function.

Fixes #7201

https://claude.ai/code/session_015Xz2nHC12pNkADGjGZnSXd

* Add release notes for PR #7202

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Matiss Janis Aboltins
2026-03-15 08:13:55 +00:00
committed by GitHub
parent 8934df0cb5
commit 328b36f124
3 changed files with 17 additions and 1 deletions

View File

@@ -11,7 +11,10 @@ export function isNonProductionEnvironment() {
}
export function isElectron() {
if (navigator.userAgent.indexOf('Electron') >= 0) {
if (
typeof navigator !== 'undefined' &&
navigator.userAgent.indexOf('Electron') >= 0
) {
return true;
}
return false;

View File

@@ -0,0 +1,7 @@
export const isPlaywright = false;
export const OS: 'windows' | 'mac' | 'linux' | 'unknown' = 'unknown';
export const env: 'web' | 'mobile' | 'unknown' = 'unknown';
export const isBrowser: boolean = false;
export const isIOSAgent = false;