Skip to content

Commit b5dec61

Browse files
feat(site): show metadata stale data (#8745)
1 parent 9ffbdc6 commit b5dec61

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

site/src/components/Resources/AgentMetadata.stories.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Example.args = {
5757
{
5858
result: {
5959
...resultDefaults,
60-
value: "cant see it",
60+
value: "stale value",
6161
age: 300,
6262
},
6363
description: {
@@ -76,18 +76,7 @@ Example.args = {
7676
description: {
7777
...descriptionDefaults,
7878
display_name: "Error",
79-
},
80-
},
81-
{
82-
result: {
83-
...resultDefaults,
84-
value: "oops",
85-
error: "fatal error",
86-
},
87-
description: {
88-
...descriptionDefaults,
89-
display_name: "Error",
90-
key: "stale",
79+
key: "error",
9180
},
9281
},
9382
{

site/src/components/Resources/AgentMetadata.tsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import dayjs from "dayjs"
66
import { createContext, FC, useContext, useEffect, useState } from "react"
77
import Skeleton from "@mui/material/Skeleton"
88
import { MONOSPACE_FONT_FAMILY } from "theme/constants"
9+
import { combineClasses } from "utils/combineClasses"
10+
import Tooltip from "@mui/material/Tooltip"
911

1012
type ItemStatus = "stale" | "valid" | "loading"
1113

@@ -44,22 +46,33 @@ const MetadataItem: FC<{ item: WorkspaceAgentMetadata }> = ({ item }) => {
4446
// users that what's shown is real. If times aren't correctly synced this
4547
// could be buggy. But, how common is that anyways?
4648
const value =
47-
status === "stale" || status === "loading" ? (
49+
status === "loading" ? (
4850
<Skeleton
4951
width={65}
5052
height={12}
5153
variant="text"
5254
className={styles.skeleton}
5355
/>
56+
) : status === "stale" ? (
57+
<Tooltip title="This data is stale and no longer up to date">
58+
<div
59+
className={combineClasses([
60+
styles.metadataValue,
61+
styles.metadataStale,
62+
])}
63+
>
64+
{item.result.value}
65+
</div>
66+
</Tooltip>
5467
) : (
5568
<div
56-
className={
57-
styles.metadataValue +
58-
" " +
59-
(item.result.error.length === 0
69+
className={combineClasses([
70+
styles.metadataValue,
71+
72+
item.result.error.length === 0
6073
? styles.metadataValueSuccess
61-
: styles.metadataValueError)
62-
}
74+
: styles.metadataValueError,
75+
])}
6376
>
6477
{item.result.value}
6578
</div>
@@ -226,6 +239,11 @@ const useStyles = makeStyles((theme) => ({
226239
color: theme.palette.error.main,
227240
},
228241

242+
metadataStale: {
243+
color: theme.palette.text.disabled,
244+
cursor: "pointer",
245+
},
246+
229247
skeleton: {
230248
marginTop: theme.spacing(0.5),
231249
},

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy