Skip to content

Commit fc0694c

Browse files
committed
fix: add back logic that was removed during merge
1 parent 0ca593b commit fc0694c

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

site/src/pages/WorkspacesPage/LastUsed.tsx

+23-6
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,33 @@ interface LastUsedProps {
1111
}
1212

1313
export const LastUsed: FC<LastUsedProps> = ({ lastUsedAt }) => {
14-
/**
15-
* @todo Verify that this is equivalent
16-
*/
1714
const [circle, message] = useTimeSync({
1815
idealRefreshIntervalMs: IDEAL_REFRESH_ONE_MINUTE,
1916
select: (date) => {
17+
/**
18+
* @todo Verify that t.from(now) is equivalent to t.fromNow()
19+
*/
2020
const t = dayjs(lastUsedAt);
21-
const deltaMsg = t.from(dayjs(date));
22-
const circle = <StatusIndicatorDot variant="inactive" />;
23-
return [circle, deltaMsg] as const;
21+
const now = dayjs(date);
22+
let message = t.from(now);
23+
let circle = <StatusIndicatorDot variant="inactive" />;
24+
25+
if (t.isAfter(now.subtract(1, "hour"))) {
26+
circle = <StatusIndicatorDot variant="success" />;
27+
// Since the agent reports on a 10m interval,
28+
// the last_used_at can be inaccurate when recent.
29+
message = "Now";
30+
} else if (t.isAfter(now.subtract(3, "day"))) {
31+
circle = <StatusIndicatorDot variant="pending" />;
32+
} else if (t.isAfter(now.subtract(1, "month"))) {
33+
circle = <StatusIndicatorDot variant="warning" />;
34+
} else if (t.isAfter(now.subtract(100, "year"))) {
35+
circle = <StatusIndicatorDot variant="failed" />;
36+
} else {
37+
message = "Never";
38+
}
39+
40+
return [circle, message] as const;
2441
},
2542
});
2643

0 commit comments

Comments
 (0)