1
1
import { faQuestionSquare , Icon } from "@rivet-gg/icons" ;
2
- import {
3
- useQuery ,
4
- useSuspenseInfiniteQuery ,
5
- useSuspenseQuery ,
6
- } from "@tanstack/react-query" ;
7
- import { useMatch } from "@tanstack/react-router" ;
8
- import { memo , type ReactNode , Suspense , useMemo } from "react" ;
9
- import { useInspectorCredentials } from "@/app/credentials-context" ;
2
+ import { useQuery } from "@tanstack/react-query" ;
3
+ import { memo , type ReactNode , Suspense } from "react" ;
10
4
import {
11
5
cn ,
12
6
Flex ,
@@ -15,26 +9,20 @@ import {
15
9
TabsList ,
16
10
TabsTrigger ,
17
11
} from "@/components" ;
18
- import { createEngineActorContext } from "@/queries/actor-engine" ;
19
- import { createInspectorActorContext } from "@/queries/actor-inspector" ;
20
- import {
21
- type NamespaceNameId ,
22
- runnersQueryOptions ,
23
- } from "@/queries/manager-engine" ;
24
12
import { ActorConfigTab } from "./actor-config-tab" ;
25
13
import { ActorConnectionsTab } from "./actor-connections-tab" ;
26
14
import { ActorDatabaseTab } from "./actor-db-tab" ;
27
15
import { ActorDetailsSettingsProvider } from "./actor-details-settings" ;
28
16
import { ActorEventsTab } from "./actor-events-tab" ;
29
17
import { ActorLogsTab } from "./actor-logs-tab" ;
30
18
import { ActorMetricsTab } from "./actor-metrics-tab" ;
31
- import { ActorProvider } from "./actor-queries-context" ;
32
19
import { ActorStateTab } from "./actor-state-tab" ;
33
20
import { QueriedActorStatus } from "./actor-status" ;
34
21
import { ActorStopButton } from "./actor-stop-button" ;
35
22
import { ActorsSidebarToggleButton } from "./actors-sidebar-toggle-button" ;
36
23
import { useActorsView } from "./actors-view-context-provider" ;
37
24
import { ActorConsole } from "./console/actor-console" ;
25
+ import { GuardConnectableInspector } from "./guard-connectable-inspector" ;
38
26
import { useManager } from "./manager-context" ;
39
27
import { ActorFeature , type ActorId } from "./queries" ;
40
28
import { ActorWorkerContextProvider } from "./worker/actor-worker-context" ;
@@ -57,34 +45,32 @@ export const ActorsActorDetails = memo(
57
45
useManager ( ) . actorFeaturesQueryOptions ( actorId ) ,
58
46
) ;
59
47
60
- const supportsConsole = features ?. includes ( ActorFeature . Console ) ;
48
+ const supportsConsole = false ;
61
49
62
50
return (
63
- < ActorContextProvider actorId = { actorId } >
64
- < ActorDetailsSettingsProvider >
65
- < ActorWorkerContextProvider
51
+ < ActorDetailsSettingsProvider >
52
+ < div className = "flex flex-col h-full flex-1" >
53
+ < ActorTabs
54
+ features = { features }
66
55
actorId = { actorId }
67
- // notifyOnReconnect={features?.includes(
68
- // ActorFeature.InspectReconnectNotification,
69
- // )}
70
- >
71
- < div className = "flex flex-col h-full flex-1" >
72
- < ActorTabs
73
- features = { features }
74
- actorId = { actorId }
75
- tab = { tab }
76
- onTabChange = { onTabChange }
77
- // onExportLogs={onExportLogs}
78
- // isExportingLogs={isExportingLogs}
79
- />
56
+ tab = { tab }
57
+ onTabChange = { onTabChange }
58
+ // onExportLogs={onExportLogs}
59
+ // isExportingLogs={isExportingLogs}
60
+ />
80
61
81
- { supportsConsole ? (
82
- < ActorConsole actorId = { actorId } />
83
- ) : null }
84
- </ div >
85
- </ ActorWorkerContextProvider >
86
- </ ActorDetailsSettingsProvider >
87
- </ ActorContextProvider >
62
+ { supportsConsole ? (
63
+ < ActorWorkerContextProvider
64
+ actorId = { actorId }
65
+ // notifyOnReconnect={features?.includes(
66
+ // ActorFeature.InspectReconnectNotification,
67
+ // )}
68
+ >
69
+ < ActorConsole actorId = { actorId } />
70
+ </ ActorWorkerContextProvider >
71
+ ) : null }
72
+ </ div >
73
+ </ ActorDetailsSettingsProvider >
88
74
) ;
89
75
} ,
90
76
) ;
@@ -234,7 +220,9 @@ export function ActorTabs({
234
220
className = "min-h-0 flex-1 mt-0 h-full"
235
221
>
236
222
< Suspense fallback = { < ActorLogsTab . Skeleton /> } >
237
- < ActorLogsTab actorId = { actorId } />
223
+ < GuardConnectableInspector actorId = { actorId } >
224
+ < ActorLogsTab actorId = { actorId } />
225
+ </ GuardConnectableInspector >
238
226
</ Suspense >
239
227
</ TabsContent >
240
228
) : null }
@@ -251,39 +239,49 @@ export function ActorTabs({
251
239
value = "connections"
252
240
className = "min-h-0 flex-1 mt-0"
253
241
>
254
- < ActorConnectionsTab actorId = { actorId } />
242
+ < GuardConnectableInspector actorId = { actorId } >
243
+ < ActorConnectionsTab actorId = { actorId } />
244
+ </ GuardConnectableInspector >
255
245
</ TabsContent >
256
246
) : null }
257
247
{ supportsEvents ? (
258
248
< TabsContent
259
249
value = "events"
260
250
className = "min-h-0 flex-1 mt-0"
261
251
>
262
- < ActorEventsTab actorId = { actorId } />
252
+ < GuardConnectableInspector actorId = { actorId } >
253
+ < ActorEventsTab actorId = { actorId } />
254
+ </ GuardConnectableInspector >
263
255
</ TabsContent >
264
256
) : null }
265
257
{ supportsDatabase ? (
266
258
< TabsContent
267
259
value = "database"
268
260
className = "min-h-0 min-w-0 flex-1 mt-0 h-full"
269
261
>
270
- < ActorDatabaseTab actorId = { actorId } />
262
+ < GuardConnectableInspector actorId = { actorId } >
263
+ < ActorDatabaseTab actorId = { actorId } />
264
+ </ GuardConnectableInspector >
271
265
</ TabsContent >
272
266
) : null }
273
267
{ supportsState ? (
274
268
< TabsContent
275
269
value = "state"
276
270
className = "min-h-0 flex-1 mt-0"
277
271
>
278
- < ActorStateTab actorId = { actorId } />
272
+ < GuardConnectableInspector actorId = { actorId } >
273
+ < ActorStateTab actorId = { actorId } />
274
+ </ GuardConnectableInspector >
279
275
</ TabsContent >
280
276
) : null }
281
277
{ supportsMetrics ? (
282
278
< TabsContent
283
279
value = "metrics"
284
280
className = "min-h-0 flex-1 mt-0 h-full"
285
281
>
286
- < ActorMetricsTab actorId = { actorId } />
282
+ < GuardConnectableInspector actorId = { actorId } >
283
+ < ActorMetricsTab actorId = { actorId } />
284
+ </ GuardConnectableInspector >
287
285
</ TabsContent >
288
286
) : null }
289
287
</ >
@@ -292,77 +290,3 @@ export function ActorTabs({
292
290
</ Tabs >
293
291
) ;
294
292
}
295
-
296
- function ActorContextProvider ( props : {
297
- actorId : ActorId ;
298
- children : ReactNode ;
299
- } ) {
300
- return __APP_TYPE__ === "inspector" ? (
301
- < ActorInspectorProvider { ...props } />
302
- ) : (
303
- < ActorEngineProvider { ...props } />
304
- ) ;
305
- }
306
-
307
- function ActorInspectorProvider ( {
308
- actorId,
309
- children,
310
- } : {
311
- actorId : ActorId ;
312
- children : ReactNode ;
313
- } ) {
314
- const { data } = useSuspenseQuery ( useManager ( ) . actorQueryOptions ( actorId ) ) ;
315
- const { credentials } = useInspectorCredentials ( ) ;
316
-
317
- if ( ! credentials ?. url || ! credentials ?. token ) {
318
- throw new Error ( "Missing inspector credentials" ) ;
319
- }
320
-
321
- const actorContext = useMemo ( ( ) => {
322
- return createInspectorActorContext ( {
323
- ...credentials ,
324
- name : data . name || "" ,
325
- } ) ;
326
- } , [ credentials , data . name ] ) ;
327
-
328
- return < ActorProvider value = { actorContext } > { children } </ ActorProvider > ;
329
- }
330
-
331
- function ActorEngineProvider ( {
332
- actorId,
333
- children,
334
- } : {
335
- actorId : ActorId ;
336
- children : ReactNode ;
337
- } ) {
338
- const { data : actor } = useSuspenseQuery (
339
- useManager ( ) . actorQueryOptions ( actorId ) ,
340
- ) ;
341
-
342
- const match = useMatch ( {
343
- from : "/_layout/ns/$namespace" ,
344
- } ) ;
345
-
346
- if ( ! match . params . namespace || ! actor . runner ) {
347
- throw new Error ( "Actor is missing required fields" ) ;
348
- }
349
-
350
- const { data : runners } = useSuspenseInfiniteQuery (
351
- runnersQueryOptions ( {
352
- namespace : match . params . namespace as NamespaceNameId ,
353
- } ) ,
354
- ) ;
355
-
356
- const runner = runners . find ( ( runner ) => runner . name === actor . runner ) ;
357
-
358
- if ( ! runner ) {
359
- throw new Error ( "Runner not found" ) ;
360
- }
361
-
362
- const actorContext = useMemo ( ( ) => {
363
- return createEngineActorContext ( {
364
- token : ( runner . metadata ?. inspectorToken as string ) || "" ,
365
- } ) ;
366
- } , [ runner . metadata ?. inspectorToken ] ) ;
367
- return < ActorProvider value = { actorContext } > { children } </ ActorProvider > ;
368
- }
0 commit comments