Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai e6ad1bee8f fix(startup): don't time out while the Trust Project prompt waits for an answer
A window opened for an untrusted project asks Trust Project over the splash.
The 60-second startup watchdog in boot.js kept counting while the prompt was up,
so answering after a minute replaced the prompt with "OpenIDEA could not start".
askOverSplash now tells boot.js when a question starts and ends, and the
watchdog pauses for that time, as it already does while the window is hidden.
2026-11-18 21:25:22 +08:00
4 змінених файлів з 58 додано та 13 видалено

No files matched your search

+19 -5
Переглянути файл
@@ -136,34 +136,48 @@
window.removeEventListener("unhandledrejection", onRejection);
window.removeEventListener("openidea:boot-error", onBootError);
window.removeEventListener("openidea:boot-ready", onReady);
window.removeEventListener("openidea:boot-question", onQuestion);
window.removeEventListener("openidea:boot-answer", onAnswer);
document.removeEventListener("visibilitychange", onVisibility);
};
// The timeout counts only while the window shows: a hidden or covered window gets no
// animation frames, and the splash waits for those to finish startup.
// The timeout counts only while the window shows and nothing waits for the user: a hidden
// or covered window gets no animation frames, and the splash waits for those to finish
// startup; a question asked over the splash (Trust Project) holds it until answered.
let remaining = 60_000;
let armedAt = 0;
let timer;
let questions = 0;
const arm = () => {
if (failed || ready || timer !== undefined || document.hidden) return;
if (failed || ready || timer !== undefined || document.hidden || questions > 0) return;
armedAt = Date.now();
timer = window.setTimeout(
() => show(rejection === undefined ? text.timeout : `${text.timeout}\n\nUnhandled rejection: ${rejection}`),
remaining,
);
};
const onVisibility = () => {
if (!document.hidden) return arm();
const pause = () => {
if (timer === undefined) return;
window.clearTimeout(timer);
timer = undefined;
remaining -= Date.now() - armedAt;
};
const onVisibility = () => (document.hidden ? pause() : arm());
const onQuestion = () => {
questions += 1;
pause();
};
const onAnswer = () => {
questions = Math.max(0, questions - 1);
arm();
};
arm();
document.addEventListener("visibilitychange", onVisibility);
window.addEventListener("error", onError, true);
window.addEventListener("unhandledrejection", onRejection);
window.addEventListener("openidea:boot-error", onBootError);
window.addEventListener("openidea:boot-ready", onReady);
window.addEventListener("openidea:boot-question", onQuestion);
window.addEventListener("openidea:boot-answer", onAnswer);
})();
// Runs before the app's CSS loads: restores the last theme (theme.ts stores it)
+12
Переглянути файл
@@ -116,6 +116,18 @@ it("counts the startup timeout only while the window shows", () => {
}
});
it("doesn't count the startup timeout while a question over the splash waits for the user", () => {
vi.advanceTimersByTime(50_000);
window.dispatchEvent(new Event("openidea:boot-question"));
vi.advanceTimersByTime(120_000);
expect(document.getElementById("boot-error")).toBeNull();
window.dispatchEvent(new Event("openidea:boot-answer"));
vi.advanceTimersByTime(9_000);
expect(document.getElementById("boot-error")).toBeNull();
vi.advanceTimersByTime(1_000);
expect(document.querySelector("textarea")?.value).toContain("Startup did not finish within 60 seconds.");
});
it("preserves the first failure", () => {
window.dispatchEvent(new ErrorEvent("error", { error: new Error("startup failed") }));
window.dispatchEvent(new ErrorEvent("error", { message: "later failure" }));
+19 -7
Переглянути файл
@@ -23,13 +23,25 @@ it("stays up, under dialogs, until a question asked while the window opens is an
const question = new Promise<boolean>((resolve) => (answer = resolve));
holdSplash(question);
hideSplash();
askOverSplash(question);
expect(splash()?.classList.contains("splash-under-dialogs")).toBe(true);
await vi.advanceTimersByTimeAsync(60_000);
expect(splash()).not.toBeNull();
answer(false);
await vi.advanceTimersByTimeAsync(1000);
expect(splash()).toBeNull();
const events: string[] = [];
const record = (e: Event) => events.push(e.type);
window.addEventListener("openidea:boot-question", record);
window.addEventListener("openidea:boot-answer", record);
try {
askOverSplash(question);
expect(splash()?.classList.contains("splash-under-dialogs")).toBe(true);
// The startup timeout pauses while the user answers.
expect(events).toEqual(["openidea:boot-question"]);
await vi.advanceTimersByTimeAsync(60_000);
expect(splash()).not.toBeNull();
answer(false);
await vi.advanceTimersByTimeAsync(1000);
expect(splash()).toBeNull();
expect(events).toEqual(["openidea:boot-question", "openidea:boot-answer"]);
} finally {
window.removeEventListener("openidea:boot-question", record);
window.removeEventListener("openidea:boot-answer", record);
}
});
it("leaves a page without a splash alone", async () => {
+8 -1
Переглянути файл
@@ -31,7 +31,14 @@ export function askOverSplash(question: Promise<unknown>): void {
const el = document.getElementById("splash");
if (!el || el.classList.contains("splash-out")) return;
el.classList.add("splash-under-dialogs");
const answered: Promise<unknown> = question.catch(() => {}).finally(() => questions.delete(answered));
// The startup timeout (boot.js) doesn't count while the user takes their time to answer.
window.dispatchEvent(new Event("openidea:boot-question"));
const answered: Promise<unknown> = question
.catch(() => {})
.finally(() => {
questions.delete(answered);
window.dispatchEvent(new Event("openidea:boot-answer"));
});
questions.add(answered);
}