Skip to content

Commit c14aa65

Browse files
committed
test
1 parent cc50c38 commit c14aa65

File tree

8 files changed

+104
-36
lines changed

8 files changed

+104
-36
lines changed

apps/array/forge.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import { VitePlugin } from "@electron-forge/plugin-vite";
77
import { PublisherGithub } from "@electron-forge/publisher-github";
88
import type { ForgeConfig } from "@electron-forge/shared-types";
99

10+
// DEBUG: Log ARRAY_* env vars when forge config is loaded
11+
console.log("[forge.config.ts] ARRAY_* env vars:");
12+
for (const [key, value] of Object.entries(process.env)) {
13+
if (key.startsWith("ARRAY_")) {
14+
console.log(` ${key}=${value}`);
15+
}
16+
}
17+
1018
const appleCodesignIdentity = process.env.APPLE_CODESIGN_IDENTITY;
1119
const appleTeamId = process.env.APPLE_TEAM_ID;
1220
const appleId = process.env.APPLE_ID;

apps/array/src/main/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ import {
1010
type MenuItemConstructorOptions,
1111
shell,
1212
} from "electron";
13+
14+
// DEBUG: Log all ARRAY_* env vars at startup
15+
console.log("[DEBUG] Main process env vars:");
16+
for (const [key, value] of Object.entries(process.env)) {
17+
if (key.startsWith("ARRAY_")) {
18+
console.log(` ${key}=${value}`);
19+
}
20+
}
21+
1322
import "./lib/logger";
1423
import { ANALYTICS_EVENTS } from "../types/analytics.js";
1524
import {

apps/array/src/main/lib/shellManager.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,24 @@ class ShellManagerImpl {
103103
});
104104

105105
ptyProcess.onData((data: string) => {
106-
webContents.send(`shell:data:${sessionId}`, data);
106+
try {
107+
if (!webContents.isDestroyed()) {
108+
webContents.send(`shell:data:${sessionId}`, data);
109+
}
110+
} catch {
111+
// webContents was destroyed, ignore
112+
}
107113
});
108114

109115
ptyProcess.onExit(({ exitCode }) => {
110116
log.info(`Shell session ${sessionId} exited with code ${exitCode}`);
111-
webContents.send(`shell:exit:${sessionId}`, { exitCode });
117+
try {
118+
if (!webContents.isDestroyed()) {
119+
webContents.send(`shell:exit:${sessionId}`, { exitCode });
120+
}
121+
} catch {
122+
// webContents was destroyed, ignore
123+
}
112124
this.sessions.delete(sessionId);
113125
resolveExit({ exitCode });
114126
});

apps/array/src/main/services/fileWatcher.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,19 @@ class FileService {
210210

211211
private emit(channel: string, data: unknown): void {
212212
try {
213-
if (
214-
this.mainWindow &&
215-
!this.mainWindow.isDestroyed() &&
216-
this.mainWindow.webContents &&
217-
!this.mainWindow.webContents.isDestroyed()
218-
) {
219-
this.mainWindow.webContents.send(channel, data);
220-
}
213+
const win = this.mainWindow;
214+
if (!win) return;
215+
216+
// Check if window is destroyed before accessing webContents
217+
if (typeof win.isDestroyed === "function" && win.isDestroyed()) return;
218+
219+
const wc = win.webContents;
220+
if (!wc) return;
221+
222+
// Check if webContents is destroyed before sending
223+
if (typeof wc.isDestroyed === "function" && wc.isDestroyed()) return;
224+
225+
wc.send(channel, data);
221226
} catch {
222227
// Window or webContents was destroyed, ignore
223228
}

apps/array/src/main/services/session-manager.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,13 @@ export class SessionManager {
385385
clientStreams: { readable: ReadableStream; writable: WritableStream },
386386
): ClientSideConnection {
387387
const emitToRenderer = (payload: unknown) => {
388-
const win = this.getMainWindow();
389-
if (win && !win.isDestroyed()) {
390-
win.webContents.send(channel, payload);
388+
try {
389+
const win = this.getMainWindow();
390+
if (win && !win.isDestroyed() && !win.webContents.isDestroyed()) {
391+
win.webContents.send(channel, payload);
392+
}
393+
} catch {
394+
// Window or webContents was destroyed, ignore
391395
}
392396
};
393397

apps/array/src/main/services/workspace/scriptRunner.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,20 @@ export class ScriptRunner {
162162
private emitTerminalCreated(
163163
info: WorkspaceTerminalInfo & { taskId: string },
164164
): void {
165-
const mainWindow = this.getMainWindow();
166-
if (!mainWindow) {
167-
log.warn("No main window available to emit terminal created event");
168-
return;
165+
try {
166+
const mainWindow = this.getMainWindow();
167+
if (
168+
!mainWindow ||
169+
mainWindow.isDestroyed() ||
170+
mainWindow.webContents.isDestroyed()
171+
) {
172+
log.warn("No main window available to emit terminal created event");
173+
return;
174+
}
175+
mainWindow.webContents.send("workspace:terminal-created", info);
176+
} catch {
177+
// Window or webContents was destroyed, ignore
169178
}
170-
mainWindow.webContents.send("workspace:terminal-created", info);
171179
}
172180
}
173181

apps/array/src/main/services/workspace/workspaceService.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,17 @@ export class WorkspaceService {
643643
}
644644

645645
private emitWorkspaceError(taskId: string, message: string): void {
646-
const mainWindow = this.getMainWindow();
647-
if (mainWindow) {
648-
mainWindow.webContents.send("workspace:error", { taskId, message });
646+
try {
647+
const mainWindow = this.getMainWindow();
648+
if (
649+
mainWindow &&
650+
!mainWindow.isDestroyed() &&
651+
!mainWindow.webContents.isDestroyed()
652+
) {
653+
mainWindow.webContents.send("workspace:error", { taskId, message });
654+
}
655+
} catch {
656+
// Window or webContents was destroyed, ignore
649657
}
650658
}
651659

@@ -654,13 +662,21 @@ export class WorkspaceService {
654662
title: string,
655663
message: string,
656664
): void {
657-
const mainWindow = this.getMainWindow();
658-
if (mainWindow) {
659-
mainWindow.webContents.send("workspace:warning", {
660-
taskId,
661-
title,
662-
message,
663-
});
665+
try {
666+
const mainWindow = this.getMainWindow();
667+
if (
668+
mainWindow &&
669+
!mainWindow.isDestroyed() &&
670+
!mainWindow.webContents.isDestroyed()
671+
) {
672+
mainWindow.webContents.send("workspace:warning", {
673+
taskId,
674+
title,
675+
message,
676+
});
677+
}
678+
} catch {
679+
// Window or webContents was destroyed, ignore
664680
}
665681
}
666682
}

scripts/start.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22
set -e
33

4+
echo "DEBUG: ARRAY_WORKSPACE_NAME=$ARRAY_WORKSPACE_NAME"
5+
echo "DEBUG: ARRAY_WORKSPACE_PATH=$ARRAY_WORKSPACE_PATH"
6+
47
cd "$ARRAY_WORKSPACE_PATH"
58
ARRAY_APP_IDENTIFIER="com.posthog.array.$ARRAY_WORKSPACE_NAME"
69
WORKSPACE_DATA_DIR="$HOME/Library/Application Support/$ARRAY_APP_IDENTIFIER"
@@ -14,12 +17,15 @@ fi
1417
VITE_CACHE_DIR="$WORKSPACE_DATA_DIR/vite-cache"
1518
mkdir -p "$VITE_CACHE_DIR"
1619

17-
# Maybe we should export these instead
18-
ARRAY_WORKSPACE_NAME="$ARRAY_WORKSPACE_NAME" \
19-
ARRAY_WORKSPACE_PATH="$ARRAY_WORKSPACE_PATH" \
20-
ARRAY_ROOT_PATH="$ARRAY_ROOT_PATH" \
21-
ARRAY_APP_IDENTIFIER="$ARRAY_APP_IDENTIFIER" \
22-
ARRAY_WORKSPACE_DATA_DIR="$WORKSPACE_DATA_DIR" \
23-
VITE_DEV_SERVER_PORT="$ARRAY_WORKSPACE_PORTS_START" \
24-
VITE_CACHE_DIR="$VITE_CACHE_DIR" \
20+
# Export all env vars so they're available to child processes
21+
export ARRAY_WORKSPACE_NAME
22+
export ARRAY_WORKSPACE_PATH
23+
export ARRAY_ROOT_PATH
24+
export ARRAY_APP_IDENTIFIER
25+
export ARRAY_WORKSPACE_DATA_DIR="$WORKSPACE_DATA_DIR"
26+
export VITE_DEV_SERVER_PORT="$ARRAY_WORKSPACE_PORTS_START"
27+
export VITE_CACHE_DIR
28+
29+
echo "DEBUG: Exported ARRAY_WORKSPACE_NAME=$ARRAY_WORKSPACE_NAME"
30+
2531
pnpm dev

0 commit comments

Comments
 (0)