Skip to content

Commit c6eb054

Browse files
author
colinmcneil
committed
Improve secret state in prompt card
1 parent 50b0a88 commit c6eb054

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/extension/ui/src/components/PromptCard.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Card, CardActions, CardContent, CardMedia, Typography } from "@mui/mate
44
import { Ref } from "../Refs";
55
import { useEffect, useState } from "react";
66
import { trackEvent } from "../Usage";
7-
import { Article, AttachFile, Build, CheckBox, Delete, LockReset, LockRounded, Save } from "@mui/icons-material";
7+
import { Article, AttachFile, Build, CheckBox, Delete, LockOpenRounded, LockReset, LockRounded, NoEncryptionGmailerrorred, Save } from "@mui/icons-material";
88
import Secrets from "../Secrets";
99
import { DD_BUILD_WITH_SECRET_SUPPORT, getUnsupportedSecretMessage } from "../Constants";
1010

@@ -34,6 +34,7 @@ export function CatalogItemCard({ openUrl, item, canRegister, registered, regist
3434
const [assignedSecrets, setAssignedSecrets] = useState<{ name: string, assigned: boolean }[]>([])
3535
const [changedSecrets, setChangedSecrets] = useState<{ [key: string]: string | undefined }>({})
3636
const [secretLoading, setSecretLoading] = useState(false)
37+
const [tooltipOpen, setTooltipOpen] = useState(false) // Tooltip is controlled because it needs to be programatically closed.
3738

3839
useEffect(() => {
3940
loadAssignedSecrets()
@@ -127,6 +128,9 @@ export function CatalogItemCard({ openUrl, item, canRegister, registered, regist
127128
<List subheader={<Typography sx={{ fontWeight: 'bold' }}>Expected secrets:</Typography>} dense sx={{ p: 0 }}>
128129
{item.secrets.map(secret => (
129130
<ListItem key={secret.name}>
131+
<ListItemIcon>
132+
{assignedSecrets.find(s => s.name === secret.name)?.assigned ? <LockRounded sx={{ color: 'success.main' }} /> : <NoEncryptionGmailerrorred sx={{ color: 'warning.main' }} />}
133+
</ListItemIcon>
130134
<ListItemText primary={secret.name} />
131135
</ListItem>
132136
))}
@@ -148,12 +152,13 @@ export function CatalogItemCard({ openUrl, item, canRegister, registered, regist
148152
</Tooltip>
149153
))}
150154
</Stack>
151-
<Tooltip title={hasAllSecrets ? registered ? "Blocking this tile will remove its tools, resources and prompts from being used in any MCP clients you have connected." : "Allowing this tile will expose its tools, resources and prompts to any MCP clients you have connected." : "You need to set all expected secrets to allow this tile."}>
155+
<Tooltip open={tooltipOpen} onClose={() => setTooltipOpen(false)} onOpen={() => setTooltipOpen(true)} title={hasAllSecrets ? registered ? "Blocking this tile will remove its tools, resources and prompts from being used in any MCP clients you have connected." : "Allowing this tile will expose its tools, resources and prompts to any MCP clients you have connected." : "You need to set all expected secrets to allow this tile."}>
152156
{!hasAllSecrets ? <LockRounded /> : isRegistering ? <CircularProgress size={20} /> : <Switch
153157
size="small"
154158
color={registered ? 'success' : 'primary'}
155159
checked={registered && hasAllSecrets}
156-
onChange={(event, checked) => {
160+
onChange={() => {
161+
setTooltipOpen(false)
157162
trackEvent('registry-changed', { name: item.name, ref: item.ref, action: registered ? 'remove' : 'add' });
158163
setIsRegistering(true)
159164
if (registered) {
@@ -165,6 +170,7 @@ export function CatalogItemCard({ openUrl, item, canRegister, registered, regist
165170
setIsRegistering(false)
166171
})
167172
}
173+
168174
}}
169175
disabled={!canRegister || isRegistering}
170176
/>}

0 commit comments

Comments
 (0)