@@ -6,7 +6,7 @@ import type {
66 ScopedThreadRef ,
77} from "@t3tools/contracts" ;
88import { Smartphone , X } from "lucide-react" ;
9- import { useEffect , useMemo , useState } from "react" ;
9+ import { useEffect , useState } from "react" ;
1010
1111import { usePreviewMiniPlayerStore } from "~/previewMiniPlayerStore" ;
1212import { useRightPanelStore , type RightPanelSurface } from "~/rightPanelStore" ;
@@ -54,10 +54,7 @@ export function DevicePanel(props: {
5454 void list ( { environmentId, input : { } } ) ;
5555 } , [ environmentId , list , loaded , props . visible , hostDisabled ] ) ;
5656
57- const sessions = useMemo (
58- ( ) => state . sessions . filter ( ( session ) => session . threadId === threadId ) ,
59- [ state . sessions , threadId ] ,
60- ) ;
57+ const sessions = state . sessions . filter ( ( session ) => session . threadId === threadId ) ;
6158 const activeSession = props . surface . target
6259 ? sessions . find (
6360 ( session ) =>
@@ -71,34 +68,31 @@ export function DevicePanel(props: {
7168 )
7269 : undefined ;
7370
74- const grouped = useMemo ( ( ) => groupDevices ( state ) , [ state ] ) ;
71+ const grouped = groupDevices ( state ) ;
7572
7673 const selectDevice = async ( value : string ) => {
7774 const device = state . devices . find ( ( candidate ) => deviceKey ( candidate ) === value ) ;
7875 if ( ! device ) return ;
7976 setOperationError ( null ) ;
8077 setPendingDevice ( device ) ;
81- try {
82- const result = await open ( {
83- environmentId,
84- input : {
85- threadId,
86- hostId : device . hostId ,
87- deviceId : device . id ,
88- platform : device . platform ,
89- } ,
78+ const result = await open ( {
79+ environmentId,
80+ input : {
81+ threadId,
82+ hostId : device . hostId ,
83+ deviceId : device . id ,
84+ platform : device . platform ,
85+ } ,
86+ } ) ;
87+ if ( result . _tag === "Failure" ) setOperationError ( formatEnvironmentQueryError ( result . cause ) ) ;
88+ else
89+ useRightPanelStore . getState ( ) . openDevice ( props . threadRef , {
90+ hostId : result . value . hostId ,
91+ deviceId : result . value . deviceId ,
92+ platform : device . platform ,
93+ name : device . name ,
9094 } ) ;
91- if ( result . _tag === "Failure" ) setOperationError ( formatEnvironmentQueryError ( result . cause ) ) ;
92- else
93- useRightPanelStore . getState ( ) . openDevice ( props . threadRef , {
94- hostId : result . value . hostId ,
95- deviceId : result . value . deviceId ,
96- platform : device . platform ,
97- name : device . name ,
98- } ) ;
99- } finally {
100- setPendingDevice ( null ) ;
101- }
95+ setPendingDevice ( null ) ;
10296 } ;
10397
10498 const floatActive = ( ) => {
0 commit comments