@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 29 lines 1.28 KB
Raw
1 import * as Electron from "electron";
2 import * as Effect from "effect/Effect";
3 import * as Option from "effect/Option";
4 import * as Schema from "effect/Schema";
5
6 import * as DesktopLegacyLocalStorage from "../../app/DesktopLegacyLocalStorage.ts";
7 import * as IpcChannels from "../channels.ts";
8 import { makeIpcMethod, makeSyncIpcMethod } from "../DesktopIpc.ts";
9
10 export const takeLegacyLocalStorage = makeSyncIpcMethod({
11 channel: IpcChannels.TAKE_LEGACY_LOCAL_STORAGE_CHANNEL,
12 result: Schema.NullOr(Schema.Record(Schema.String, Schema.String)),
13 handler: Effect.fn("desktop.ipc.legacyLocalStorage.take")(function* () {
14 const legacy = yield* DesktopLegacyLocalStorage.DesktopLegacyLocalStorage;
15 return Option.getOrNull(yield* legacy.take);
16 }),
17 });
18
19 export const completeLegacyLocalStorage = makeIpcMethod({
20 channel: IpcChannels.COMPLETE_LEGACY_LOCAL_STORAGE_CHANNEL,
21 payload: Schema.Void,
22 result: Schema.Void,
23 handler: Effect.fn("desktop.ipc.legacyLocalStorage.complete")(function* (_, event) {
24 const legacy = yield* DesktopLegacyLocalStorage.DesktopLegacyLocalStorage;
25 // Flush Chromium's lazy writes before the marker prevents migration retries.
26 if (event) Electron.webContents.fromId(event.sender.id)?.session.flushStorageData();
27 yield* legacy.complete;
28 }),
29 });