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

main
ts 25 lines 971 Bytes
Raw
1 import {
2 mapAtomCommandResult,
3 type AtomCommandResult,
4 } from "@t3tools/client-runtime/state/runtime";
5 import type { ScopedThreadRef } from "@t3tools/contracts";
6
7 import type { BrowserSettingsReadError, OpenPreviewMutation } from "~/browser/openFileInPreview";
8 import { useRightPanelStore } from "~/rightPanelStore";
9
10 import { openPreviewSession } from "./openPreviewSession";
11
12 export async function addBrowserSurface<E>(input: {
13 readonly threadRef: ScopedThreadRef;
14 readonly openPreview: OpenPreviewMutation<E>;
15 readonly profileId?: string | undefined;
16 }): Promise<AtomCommandResult<void, E | BrowserSettingsReadError>> {
17 const result = await openPreviewSession({
18 openPreview: input.openPreview,
19 threadRef: input.threadRef,
20 ...(input.profileId === undefined ? {} : { profileId: input.profileId }),
21 });
22 return mapAtomCommandResult(result, (snapshot) => {
23 useRightPanelStore.getState().openBrowser(input.threadRef, snapshot.tabId);
24 });
25 }