54fc313e10
Frontend CI / Frontend (push) Successful in 2m18s
- Track each window's renderer mode in a WeakMap (and fall back to parsing ?window= from the URL) so retireInactiveAppWindows can destroy stale login/main/settings windows when we switch modes, not just the previous one of the canonical pair. - Replace closeWindowAfterIpcReturn with retireWindowAfterIpcReturn (hides immediately, then destroys instead of close()) so the IPC reply still reaches the caller before teardown. - Add waitForWindowReady() with a 1.2s ceiling and call it from revealWindow so we don't show a half-loaded shell while switchWindowMode is running. Pass the source window from the IPC event into switchWindowMode so the closing target is the actual caller, not a guess based on mode. - Silence console.* and skip the observed-fetch install in packaged runtime, and only auto-openDevTools in dev. - Eagerly import LoginView in App.vue instead of defineAsyncComponent to remove the boot flash on the login window. - package.json: prefix package:* with `pnpm run build` and add package:win and package:linux for parity. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
84 lines
2.3 KiB
Vue
84 lines
2.3 KiB
Vue
<script setup lang="ts">
|
|
import { computed, defineAsyncComponent, onMounted, watch } from "vue";
|
|
import { useDesktopSession } from "./composables/useDesktopSession";
|
|
import LoginView from "./views/LoginView.vue";
|
|
|
|
const DesktopShell = defineAsyncComponent(() => import("./components/DesktopShell.vue"));
|
|
const SettingsWindow = defineAsyncComponent(() => import("./views/SettingsWindow.vue"));
|
|
|
|
const { isAuthenticated, syncRuntimeSession } = useDesktopSession();
|
|
type RendererWindowMode = "auto" | "login" | "main" | "settings";
|
|
|
|
interface WindowModeBridge {
|
|
setWindowMode?: (
|
|
mode: "login" | "main",
|
|
request?: { source?: "auth-state" | "login" | "logout"; animate?: boolean },
|
|
) => Promise<unknown>;
|
|
}
|
|
|
|
function resolveRendererWindowMode(): RendererWindowMode {
|
|
const mode = new URLSearchParams(window.location.search).get("window");
|
|
return mode === "login" || mode === "main" || mode === "settings" ? mode : "auto";
|
|
}
|
|
|
|
function getModeBridge(): WindowModeBridge | undefined {
|
|
return (globalThis as unknown as {
|
|
desktopBridge?: { app?: WindowModeBridge };
|
|
}).desktopBridge?.app;
|
|
}
|
|
|
|
function syncWindowMode(authenticated: boolean): void {
|
|
void getModeBridge()?.setWindowMode?.(authenticated ? "main" : "login", { source: "auth-state" });
|
|
}
|
|
|
|
const rendererWindowMode = resolveRendererWindowMode();
|
|
document.documentElement.dataset.windowMode = rendererWindowMode;
|
|
const usesAutomaticWindowMode = rendererWindowMode === "auto";
|
|
const showsSettingsSurface = rendererWindowMode === "settings";
|
|
const showsMainSurface = computed(() =>
|
|
rendererWindowMode === "main" || (rendererWindowMode === "auto" && isAuthenticated.value),
|
|
);
|
|
|
|
if (usesAutomaticWindowMode) {
|
|
syncWindowMode(isAuthenticated.value);
|
|
watch(isAuthenticated, (next) => syncWindowMode(next));
|
|
}
|
|
|
|
if (rendererWindowMode === "main") {
|
|
if (!isAuthenticated.value) {
|
|
syncWindowMode(false);
|
|
}
|
|
watch(isAuthenticated, (next) => {
|
|
if (!next) {
|
|
syncWindowMode(false);
|
|
}
|
|
});
|
|
}
|
|
|
|
onMounted(() => {
|
|
if (rendererWindowMode !== "login") {
|
|
void syncRuntimeSession();
|
|
}
|
|
if (usesAutomaticWindowMode) {
|
|
syncWindowMode(isAuthenticated.value);
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<SettingsWindow v-if="showsSettingsSurface" />
|
|
<DesktopShell v-else-if="showsMainSurface" />
|
|
<LoginView v-else />
|
|
</template>
|
|
|
|
<style>
|
|
html,
|
|
body,
|
|
#app {
|
|
width: 100%;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
}
|
|
|
|
</style>
|