11"use client"
22
3- import { useEffect , useState } from "react"
3+ import { useEffect } from "react"
44import Link from "next/link"
55import { useQuery } from "@tanstack/react-query"
66import { PageHeader } from "@/components/page-header"
@@ -18,25 +18,6 @@ import { useActiveScope } from "@/lib/active-scope"
1818const EVENTS_REFRESH_SECONDS = 30
1919const HEATMAP_COLOR_SCALE = [ CHART_COLORS . grid , "#1d4ed8" , "#3b82f6" , "#60a5fa" , "#93c5fd" ]
2020
21- // Isolated into its own component so the 1s tick only re-renders this small chip,
22- // not the whole page (and the feed/job lists below it).
23- function RefreshCountdown ( { resetKey, seconds } : { resetKey : number ; seconds : number } ) {
24- const [ remaining , setRemaining ] = useState ( seconds )
25-
26- useEffect ( ( ) => {
27- setRemaining ( seconds )
28- } , [ resetKey , seconds ] )
29-
30- useEffect ( ( ) => {
31- const interval = setInterval ( ( ) => {
32- setRemaining ( ( r ) => ( r > 0 ? r - 1 : 0 ) )
33- } , 1000 )
34- return ( ) => clearInterval ( interval )
35- } , [ ] )
36-
37- return < span className = "stat-chip" > refreshes in { remaining } s</ span >
38- }
39-
4021export default function ActivityPage ( ) {
4122 // Marks all cockpit-sourced events as read so the sidebar's unread badge
4223 // clears once the user has actually looked at this page.
@@ -78,10 +59,6 @@ export default function ActivityPage() {
7859 refetchInterval : EVENTS_REFRESH_SECONDS * 1000 ,
7960 } )
8061
81- // Reset the countdown on either a successful fetch OR a failed one, so it always
82- // tracks the real refetchInterval cadence instead of sticking at 0 after an error.
83- const lastAttemptAt = Math . max ( eventsQuery . dataUpdatedAt , eventsQuery . errorUpdatedAt )
84-
8562 // Heatmap data rides on the personal cockpit endpoint (commit_heatmap_52w) --
8663 // that endpoint is personal-scoped (no OrgMembership needed), unlike the
8764 // org-scoped failed-runs/release-timeline calls below, but the same resolved
@@ -127,7 +104,7 @@ export default function ActivityPage() {
127104 < div className = "lg:col-span-2 card" >
128105 < div className = "px-4 py-3 border-b border-border flex items-center justify-between gap-3" >
129106 < span className = "section-label" > Activity Feed</ span >
130- { hasOrg && < RefreshCountdown resetKey = { lastAttemptAt } seconds = { EVENTS_REFRESH_SECONDS } / >}
107+ { hasOrg && < span className = "stat-chip" > auto-refreshes every { EVENTS_REFRESH_SECONDS } s </ span > }
131108 </ div >
132109 { ! hasOrg ? (
133110 < EmptyStateNoAccount bare />
0 commit comments