@@ -10,12 +10,13 @@ import {
1010 VideoCameraIcon ,
1111} from "@heroicons/react/20/solid" ;
1212import { json , type MetaFunction } from "@remix-run/node" ;
13- import { Link , useRevalidator , useSubmit } from "@remix-run/react" ;
13+ import { Link , useFetcher , useRevalidator } from "@remix-run/react" ;
1414import { type ActionFunctionArgs , type LoaderFunctionArgs } from "@remix-run/server-runtime" ;
1515import { DiscordIcon } from "@trigger.dev/companyicons" ;
1616import { formatDurationMilliseconds } from "@trigger.dev/core/v3" ;
1717import type { TaskRunStatus } from "@trigger.dev/database" ;
18- import { Fragment , Suspense , useEffect , useState } from "react" ;
18+ import { Fragment , Suspense , useCallback , useEffect , useRef , useState } from "react" ;
19+ import type { PanelHandle } from "react-window-splitter" ;
1920import { Bar , BarChart , ResponsiveContainer , Tooltip , type TooltipProps } from "recharts" ;
2021import { TypedAwait , typeddefer , useTypedLoaderData } from "remix-typedjson" ;
2122import { ExitIcon } from "~/assets/icons/ExitIcon" ;
@@ -42,9 +43,11 @@ import { Paragraph } from "~/components/primitives/Paragraph";
4243import { PopoverMenuItem } from "~/components/primitives/Popover" ;
4344import * as Property from "~/components/primitives/PropertyTable" ;
4445import {
46+ RESIZABLE_PANEL_ANIMATION ,
4547 ResizableHandle ,
4648 ResizablePanel ,
4749 ResizablePanelGroup ,
50+ collapsibleHandleClassName ,
4851} from "~/components/primitives/Resizable" ;
4952import { Spinner } from "~/components/primitives/Spinner" ;
5053import { StepNumber } from "~/components/primitives/StepNumber" ;
@@ -192,14 +195,20 @@ export default function Page() {
192195 } , [ streamedEvents ] ) ; // eslint-disable-line react-hooks/exhaustive-deps
193196
194197 const [ showUsefulLinks , setShowUsefulLinks ] = useState ( usefulLinksPreference ?? true ) ;
198+ const usefulLinksPanelRef = useRef < PanelHandle > ( null ) ;
199+ const fetcher = useFetcher ( ) ;
200+ const fetcherRef = useRef ( fetcher ) ;
201+ fetcherRef . current = fetcher ;
195202
196- // Create a submit handler to save the preference
197- const submit = useSubmit ( ) ;
198-
199- const handleUsefulLinksToggle = ( show : boolean ) => {
203+ const toggleUsefulLinks = useCallback ( ( show : boolean ) => {
200204 setShowUsefulLinks ( show ) ;
201- submit ( { showUsefulLinks : show . toString ( ) } , { method : "post" } ) ;
202- } ;
205+ if ( show ) {
206+ usefulLinksPanelRef . current ?. expand ( ) ;
207+ } else {
208+ usefulLinksPanelRef . current ?. collapse ( ) ;
209+ }
210+ fetcherRef . current . submit ( { showUsefulLinks : show . toString ( ) } , { method : "post" } ) ;
211+ } , [ ] ) ;
203212
204213 return (
205214 < PageContainer >
@@ -226,7 +235,7 @@ export default function Page() {
226235 </ NavBar >
227236 < PageBody scrollable = { false } >
228237 < ResizablePanelGroup orientation = "horizontal" className = "max-h-full" >
229- < ResizablePanel id = "tasks-main" className = "max-h-full" >
238+ < ResizablePanel id = "tasks-main" min = "100px" className = "max-h-full" >
230239 < div className = { cn ( "grid h-full grid-rows-1" ) } >
231240 { hasTasks ? (
232241 < div className = "flex min-w-0 max-w-full flex-col" >
@@ -244,9 +253,9 @@ export default function Page() {
244253 />
245254 { ! showUsefulLinks && (
246255 < Button
247- variant = "minimal /small"
256+ variant = "secondary /small"
248257 TrailingIcon = { LightBulbIcon }
249- onClick = { ( ) => handleUsefulLinksToggle ( true ) }
258+ onClick = { ( ) => toggleUsefulLinks ( true ) }
250259 className = "px-2.5"
251260 />
252261 ) }
@@ -417,20 +426,31 @@ export default function Page() {
417426 ) }
418427 </ div >
419428 </ ResizablePanel >
420- { hasTasks && showUsefulLinks ? (
421- < >
422- < ResizableHandle id = "tasks-handle" />
423- < ResizablePanel
424- id = "tasks-inspector"
425- min = "200px"
426- default = "400px"
427- max = "500px"
428- className = "w-full"
429- >
430- < HelpfulInfoHasTasks onClose = { ( ) => handleUsefulLinksToggle ( false ) } />
431- </ ResizablePanel >
432- </ >
433- ) : null }
429+ < ResizableHandle
430+ id = "tasks-handle"
431+ className = { collapsibleHandleClassName ( hasTasks && showUsefulLinks ) }
432+ />
433+ < ResizablePanel
434+ id = "tasks-inspector"
435+ handle = { usefulLinksPanelRef }
436+ default = "400px"
437+ min = "400px"
438+ max = "500px"
439+ className = "overflow-hidden"
440+ collapsible
441+ collapsed = { ! hasTasks || ! showUsefulLinks }
442+ onCollapseChange = { ( isCollapsed ) => {
443+ if ( isCollapsed ) setShowUsefulLinks ( false ) ;
444+ } }
445+ collapsedSize = "0px"
446+ collapseAnimation = { RESIZABLE_PANEL_ANIMATION }
447+ >
448+ < div className = "h-full" style = { { minWidth : 400 } } >
449+ { hasTasks && (
450+ < HelpfulInfoHasTasks onClose = { ( ) => toggleUsefulLinks ( false ) } />
451+ ) }
452+ </ div >
453+ </ ResizablePanel >
434454 </ ResizablePanelGroup >
435455 </ PageBody >
436456 </ PageContainer >
0 commit comments