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

guestShareDialogState.ts

26 lines1006 Bytes

1import { scopedThreadKey } from "@t3tools/client-runtime/environment";
2import type { ScopedThreadRef } from "@t3tools/contracts";
3import { Atom } from "effect/reactivity";
4​
5import { appAtomRegistry } from "~/rpc/atomRegistry";
6import { registerThreadOverlay } from "./threadOverlayRetention";
7​
8/**
9 * Which thread has the guest share dialog open. The thread menu and the command palette both
10 * close as their command runs, so the chat view renders the dialog once.
11 */
12export const guestShareDialogThreadAtom = Atom.make<ScopedThreadRef | null>(null).pipe(
13 Atom.keepAlive,
14 Atom.withLabel("guest-share:dialog-thread"),
15);
16​
17registerThreadOverlay((threadKey) => {
18 const current = appAtomRegistry.get(guestShareDialogThreadAtom);
19 if (current !== null && scopedThreadKey(current) !== threadKey) {
20 appAtomRegistry.set(guestShareDialogThreadAtom, null);
21 }
22});
23​
24export function openGuestShareDialog(threadRef: ScopedThreadRef): void {
25 appAtomRegistry.set(guestShareDialogThreadAtom, threadRef);