1
1
import {
2
+ BoltSlashIcon ,
2
3
ChevronDownIcon ,
3
4
ChevronRightIcon ,
4
5
MagnifyingGlassMinusIcon ,
@@ -69,6 +70,9 @@ import {
69
70
import { SpanView } from "../resources.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam.spans.$spanParam/route" ;
70
71
import { AdminDebugTooltip } from "~/components/admin/debugTooltip" ;
71
72
import { Property , PropertyTable } from "~/components/primitives/PropertyTable" ;
73
+ import { SimpleTooltip } from "~/components/primitives/Tooltip" ;
74
+
75
+ const MAX_LIVE_RELOADING_EVENTS = 500 ;
72
76
73
77
export const loader = async ( { request, params } : LoaderFunctionArgs ) => {
74
78
const userId = await requireUserId ( request ) ;
@@ -167,6 +171,7 @@ export default function Page() {
167
171
}
168
172
169
173
const { events, parentRunFriendlyId, duration, rootSpanStatus, rootStartedAt } = trace ;
174
+ const shouldLiveReload = events . length <= MAX_LIVE_RELOADING_EVENTS ;
170
175
171
176
const changeToSpan = useDebounce ( ( selectedSpan : string ) => {
172
177
replaceSearchParam ( "span" , selectedSpan ) ;
@@ -175,6 +180,7 @@ export default function Page() {
175
180
const revalidator = useRevalidator ( ) ;
176
181
const streamedEvents = useEventSource ( v3RunStreamingPath ( organization , project , run ) , {
177
182
event : "message" ,
183
+ disabled : ! shouldLiveReload ,
178
184
} ) ;
179
185
useEffect ( ( ) => {
180
186
if ( streamedEvents !== null ) {
@@ -254,6 +260,7 @@ export default function Page() {
254
260
rootSpanStatus = { rootSpanStatus }
255
261
rootStartedAt = { rootStartedAt }
256
262
environmentType = { run . environment . type }
263
+ shouldLiveReload = { shouldLiveReload }
257
264
/>
258
265
</ ResizablePanel >
259
266
< ResizableHandle withHandle />
@@ -282,6 +289,7 @@ type TasksTreeViewProps = {
282
289
rootSpanStatus : "executing" | "completed" | "failed" ;
283
290
rootStartedAt : Date | undefined ;
284
291
environmentType : RuntimeEnvironmentType ;
292
+ shouldLiveReload : boolean ;
285
293
} ;
286
294
287
295
function TasksTreeView ( {
@@ -293,6 +301,7 @@ function TasksTreeView({
293
301
rootSpanStatus,
294
302
rootStartedAt,
295
303
environmentType,
304
+ shouldLiveReload,
296
305
} : TasksTreeViewProps ) {
297
306
const [ filterText , setFilterText ] = useState ( "" ) ;
298
307
const [ errorsOnly , setErrorsOnly ] = useState ( false ) ;
@@ -367,7 +376,10 @@ function TasksTreeView({
367
376
This is the root task
368
377
</ Paragraph >
369
378
) }
370
- < LiveReloadingStatus rootSpanCompleted = { rootSpanStatus !== "executing" } />
379
+ < LiveReloadingStatus
380
+ rootSpanCompleted = { rootSpanStatus !== "executing" }
381
+ isLiveReloading = { shouldLiveReload }
382
+ />
371
383
</ div >
372
384
< TreeView
373
385
parentRef = { parentRef }
@@ -834,16 +846,38 @@ function ShowParentLink({ runFriendlyId }: { runFriendlyId: string }) {
834
846
) ;
835
847
}
836
848
837
- function LiveReloadingStatus ( { rootSpanCompleted } : { rootSpanCompleted : boolean } ) {
849
+ function LiveReloadingStatus ( {
850
+ rootSpanCompleted,
851
+ isLiveReloading,
852
+ } : {
853
+ rootSpanCompleted : boolean ;
854
+ isLiveReloading : boolean ;
855
+ } ) {
838
856
if ( rootSpanCompleted ) return null ;
839
857
840
858
return (
841
- < div className = "flex items-center gap-1" >
842
- < PulsingDot />
843
- < Paragraph variant = "extra-small" className = "whitespace-nowrap text-blue-500" >
844
- Live reloading
845
- </ Paragraph >
846
- </ div >
859
+ < >
860
+ { isLiveReloading ? (
861
+ < div className = "flex items-center gap-1" >
862
+ < PulsingDot />
863
+ < Paragraph variant = "extra-small" className = "whitespace-nowrap text-blue-500" >
864
+ Live reloading
865
+ </ Paragraph >
866
+ </ div >
867
+ ) : (
868
+ < SimpleTooltip
869
+ content = { `Live reloading is disabled because you've exceeded ${ MAX_LIVE_RELOADING_EVENTS } logs.` }
870
+ button = {
871
+ < div className = "flex items-center gap-1" >
872
+ < BoltSlashIcon className = "size-3.5 text-text-dimmed" />
873
+ < Paragraph variant = "extra-small" className = "whitespace-nowrap text-text-dimmed" >
874
+ Live reloading disabled
875
+ </ Paragraph >
876
+ </ div >
877
+ }
878
+ > </ SimpleTooltip >
879
+ ) }
880
+ </ >
847
881
) ;
848
882
}
849
883
0 commit comments