Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

addBrowserSurface.ts

24 lines882 Bytes

1import {
2 mapAtomCommandResult,
3 type AtomCommandResult,
4} from "@t3tools/client-runtime/state/runtime";
5import type { ScopedThreadRef } from "@t3tools/contracts";
6​
7import type { OpenPreviewMutation } from "~/browser/openFileInPreview";
8import { useRightPanelStore } from "~/rightPanelStore";
9​
10import { openPreviewSession } from "./openPreviewSession";
11​
12/** Creates a new browser tab. Reopening an existing tab is a separate UI action. */
13export async function addBrowserSurface<E>(input: {
14 readonly threadRef: ScopedThreadRef;
15 readonly openPreview: OpenPreviewMutation<E>;
16}): Promise<AtomCommandResult<void, E>> {
17 const result = await openPreviewSession({
18 openPreview: input.openPreview,
19 threadRef: input.threadRef,
20 });
21 return mapAtomCommandResult(result, (snapshot) => {
22 useRightPanelStore.getState().openBrowser(input.threadRef, snapshot.tabId);
23 });