feat: add verified desktop ChatGPT subscription connection

This commit is contained in:
amosblomqvist
2026-10-24 12:17:08 +03:00
parent ae2fad56c4
commit 0fc6d4ab94
53 changed files with 2557 additions and 140 deletions
+10
View File
@@ -21,6 +21,7 @@ import { fuzzyScore } from "@/src/core";
import { useServerEvent, useServerResync } from "@/components/server-events";
import type { ChatListItem } from "@/src/core";
import { kbdEventForAction } from "@/src/core";
import { notifySettingsSaved } from "@/components/settings-signal";
/**
* Toggleable sidebar — NOT a modal drawer: no backdrop, no focus theft. It
@@ -47,6 +48,7 @@ const STORAGE_KEY = "lh:sidebar-open";
*
* Mirrors SIDEBAR_AUTOCLOSE in electron/main.cjs — keep in sync.
*/
import type { ChatGPTControlBridge } from "@/src/core";
const SIDEBAR_AUTOCLOSE = 928;
// Module scope, guarded for SSR (the server has no navigator).
@@ -58,6 +60,7 @@ declare global {
lh?: {
/** Read-only host OS; determines the native-control gutter. */
platform?: string;
chatgpt?: ChatGPTControlBridge;
expandWindow: () => void;
/** The zoom truth (owner round 7): subscribes to "lh:zoom" pushes; returns unsubscribe. */
onZoom?: (cb: (factor: number) => void) => () => void;
@@ -79,6 +82,13 @@ export function useSidebar() {
}
export function SidebarProvider({ children }: { children: React.ReactNode }) {
useEffect(() => {
const bridge = window.lh?.chatgpt;
if (!bridge) return;
const off = bridge.onChange(() => notifySettingsSaved("keys"));
notifySettingsSaved("keys"); // cover changes missed before this root-lifetime subscription
return off;
}, []);
// Start closed so server and client first-render agree (no hydration
// mismatch); the stored value is applied after mount.
const [open, setOpen] = useState(false);