Skip to content

Commit eb3dc4e

Browse files
committed
fix: handle headless mode for electron file operations, alerts, and prompts
1 parent 29a123f commit eb3dc4e

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

plugins/plugin-electron/src/forge.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,8 @@ export const forge = async (
861861
throw e;
862862
}
863863
} finally {
864+
const originalNoAsar = process.noAsar;
865+
process.noAsar = true;
864866
try {
865867
if (action !== "preview") {
866868
const outDir = join(destinationFolder, "out");
@@ -884,6 +886,8 @@ export const forge = async (
884886
"Failed to clean up staging directory:",
885887
e instanceof Error ? `${e.message}\n${e.stack}` : String(e),
886888
);
889+
} finally {
890+
process.noAsar = originalNoAsar;
887891
}
888892
}
889893
};

plugins/plugin-system/src/alert.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ export const alertAction = createAction({
3535

3636
export const alertActionRunner = createActionRunner<typeof alertAction>(
3737
async ({ log, inputs, setOutput, browserWindow }) => {
38+
if (!browserWindow) {
39+
log(`Alert (Headless): ${inputs.message}`);
40+
setOutput("answer", "ok");
41+
return;
42+
}
43+
3844
browserWindow.flashFrame(true);
3945
const api = usePluginAPI(browserWindow);
4046
// 'cancel' | 'ok'

plugins/plugin-system/src/prompt.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export const promptAction = createAction({
3535

3636
export const promptActionRunner = createActionRunner<typeof promptAction>(
3737
async ({ log, inputs, setOutput, browserWindow }) => {
38+
if (!browserWindow) {
39+
throw new Error("Prompt action cannot be executed in headless mode because it requires user input.");
40+
}
41+
3842
browserWindow.flashFrame(true);
3943
const api = usePluginAPI(browserWindow);
4044
// 'cancel' | 'ok'

0 commit comments

Comments
 (0)