Skip to content
Source
Sign inSign up
pingdotgg/t3code

refactor(web): move agent-opened browser and device surfacing out of ChatView #20312

Mergedjuliusmarmingemerged 1 commit intochatview-split/proactive-panels fromrefs/pull/20312/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 154 additions and 0 deletions (loading 2).

x
0 of 3 viewed, 3 left
154 additions and 0 deletionsapps/web/src/components/preview/useAgentOpenedPreviews.tsAdded
View file
@@ -0,0 +1,154 @@
+import type { DeviceServiceState, ScopedThreadRef } from "@t3tools/contracts";
+import { scopedThreadKey } from "@t3tools/client-runtime/environment";
+import { useEffect, useRef } from "react";
+import { useClientSettings } from "../../hooks/useSettings";
+import {
+ browserMiniPlayerSource,
+ usePreviewMiniPlayerStore,
+ type PreviewMiniPlayerState,
+} from "../../previewMiniPlayerStore";
+import type { ThreadPreviewState } from "../../previewStateStore";
+import { useRightPanelStore, type RightPanelSurface } from "../../rightPanelStore";
+​
+const selectAutoShowFloatingPreview = (settings: { browserAutoShowFloatingPreview: boolean }) =>
+ settings.browserAutoShowFloatingPreview;
+​
+/**
+ * Shows browsers and devices an agent or another client opened for the thread,
+ * and closes a floating device once its session ends.
+ */
+export function useAgentOpenedPreviews(input: {
+ readonly threadRef: ScopedThreadRef | null;
+ readonly deviceState: DeviceServiceState;
+ readonly deviceStateLoaded: boolean;
+ readonly previewState: ThreadPreviewState;
+ // Whether the environment hosts browser tabs for this client.
+ readonly serverBrowserAvailable: boolean;
+ readonly panelSurfaces: ReadonlyArray<RightPanelSurface>;
+ readonly miniPlayerSource: PreviewMiniPlayerState["source"] | null;
+ // Sheet layouts show neither floating previews nor auto-opened device tabs.
+ readonly sheetLayout: boolean;