-
Notifications
You must be signed in to change notification settings - Fork 1k
refactor: replace Popover with Tooltip in HelpTooltip #19635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
fba9492
e230f38
75c9fdf
bea24d8
9e6fa0c
303222b
f835cb1
dd7e233
d397fff
6134bad
ad562be
d30170c
4438af8
00b70ea
c59daf3
3aeaa49
eaf3baf
c93e092
ef6cceb
c142b5a
143e33e
d22a040
2ff9e66
ed5bf98
8f939f9
5050a92
ded8411
3466e90
3a8a403
5f79acc
b0696dd
71c1824
70e0dbf
1df04ec
6733d6a
bc12f84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,7 +7,7 @@ import { | |||||
HelpTooltipTitle, | ||||||
} from "components/HelpTooltip/HelpTooltip"; | ||||||
import { Stack } from "components/Stack/Stack"; | ||||||
import { TooltipProvider, TooltipTrigger } from "components/Tooltip/Tooltip"; | ||||||
import { TooltipTrigger } from "components/Tooltip/Tooltip"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stuff like this is making me worry we're not closing the loop on the abstraction all the way I think my preference would be to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tricky thing is that the
which is currently instantiated in 16 places like this:
So my thought with using What do you think about renaming the existing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I like the renaming approach better. I'm not even fully sure about having a version of the trigger that has an icon pre-baked, but I don't think it's all that egregious, and I imagine it'd be pretty easy to change it down the line |
||||||
import type { FC } from "react"; | ||||||
import { getLatencyColor } from "utils/latency"; | ||||||
|
||||||
|
@@ -43,45 +43,43 @@ export const AgentLatency: FC<AgentLatencyProps> = ({ agent }) => { | |||||
} | ||||||
|
||||||
return ( | ||||||
<TooltipProvider> | ||||||
<HelpTooltip> | ||||||
<TooltipTrigger asChild> | ||||||
<span | ||||||
role="presentation" | ||||||
aria-label="latency" | ||||||
css={{ cursor: "pointer", color: latency.color }} | ||||||
> | ||||||
{Math.round(latency.latency_ms)}ms | ||||||
</span> | ||||||
</TooltipTrigger> | ||||||
<HelpTooltipContent> | ||||||
<HelpTooltipTitle>Latency</HelpTooltipTitle> | ||||||
<HelpTooltipText> | ||||||
This is the latency overhead on non peer to peer connections. The | ||||||
first row is the preferred relay. | ||||||
</HelpTooltipText> | ||||||
<Stack direction="column" spacing={1} css={{ marginTop: 16 }}> | ||||||
{Object.entries(agent.latency) | ||||||
.sort(([, a], [, b]) => a.latency_ms - b.latency_ms) | ||||||
.map(([regionName, region]) => ( | ||||||
<Stack | ||||||
direction="row" | ||||||
key={regionName} | ||||||
spacing={0.5} | ||||||
justifyContent="space-between" | ||||||
css={ | ||||||
region.preferred && { | ||||||
color: theme.palette.text.primary, | ||||||
} | ||||||
<HelpTooltip> | ||||||
<TooltipTrigger asChild> | ||||||
<span | ||||||
role="presentation" | ||||||
aria-label="latency" | ||||||
css={{ cursor: "pointer", color: latency.color }} | ||||||
> | ||||||
{Math.round(latency.latency_ms)}ms | ||||||
</span> | ||||||
</TooltipTrigger> | ||||||
<HelpTooltipContent> | ||||||
<HelpTooltipTitle>Latency</HelpTooltipTitle> | ||||||
<HelpTooltipText> | ||||||
This is the latency overhead on non peer to peer connections. The | ||||||
first row is the preferred relay. | ||||||
</HelpTooltipText> | ||||||
<Stack direction="column" spacing={1} css={{ marginTop: 16 }}> | ||||||
{Object.entries(agent.latency) | ||||||
.sort(([, a], [, b]) => a.latency_ms - b.latency_ms) | ||||||
.map(([regionName, region]) => ( | ||||||
<Stack | ||||||
direction="row" | ||||||
key={regionName} | ||||||
spacing={0.5} | ||||||
justifyContent="space-between" | ||||||
css={ | ||||||
region.preferred && { | ||||||
color: theme.palette.text.primary, | ||||||
} | ||||||
> | ||||||
<strong>{regionName}</strong> | ||||||
{Math.round(region.latency_ms)}ms | ||||||
</Stack> | ||||||
))} | ||||||
</Stack> | ||||||
</HelpTooltipContent> | ||||||
</HelpTooltip> | ||||||
</TooltipProvider> | ||||||
} | ||||||
> | ||||||
<strong>{regionName}</strong> | ||||||
{Math.round(region.latency_ms)}ms | ||||||
</Stack> | ||||||
))} | ||||||
</Stack> | ||||||
</HelpTooltipContent> | ||||||
</HelpTooltip> | ||||||
); | ||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import { Stack } from "components/Stack/Stack"; | |
import { RotateCcwIcon } from "lucide-react"; | ||
import { useState, type FC } from "react"; | ||
import { agentVersionStatus } from "../../utils/workspace"; | ||
import { TooltipProvider, TooltipTrigger } from "components/Tooltip/Tooltip"; | ||
import { TooltipTrigger } from "components/Tooltip/Tooltip"; | ||
|
||
type AgentOutdatedTooltipProps = { | ||
agent: WorkspaceAgent; | ||
|
@@ -40,50 +40,48 @@ export const AgentOutdatedTooltip: FC<AgentOutdatedTooltipProps> = ({ | |
const text = `${opener} This can happen after you update Coder with running workspaces. To fix this, you can stop and start the workspace.`; | ||
|
||
return ( | ||
<TooltipProvider> | ||
<HelpTooltip open={isOpen} onOpenChange={setIsOpen}> | ||
<TooltipTrigger asChild> | ||
<span role="status" className="cursor-pointer"> | ||
{status === agentVersionStatus.Outdated ? "Outdated" : "Deprecated"} | ||
</span> | ||
</TooltipTrigger> | ||
<HelpTooltipContent> | ||
<Stack spacing={1}> | ||
<div> | ||
<HelpTooltipTitle>{title}</HelpTooltipTitle> | ||
<HelpTooltipText>{text}</HelpTooltipText> | ||
</div> | ||
<HelpTooltip open={isOpen} onOpenChange={setIsOpen}> | ||
<TooltipTrigger asChild> | ||
<span role="status" className="cursor-pointer"> | ||
{status === agentVersionStatus.Outdated ? "Outdated" : "Deprecated"} | ||
</span> | ||
</TooltipTrigger> | ||
<HelpTooltipContent> | ||
<Stack spacing={1}> | ||
<div> | ||
<HelpTooltipTitle>{title}</HelpTooltipTitle> | ||
<HelpTooltipText>{text}</HelpTooltipText> | ||
</div> | ||
|
||
<Stack spacing={0.5}> | ||
<span className="font-semibold text-content-primary"> | ||
Agent version | ||
</span> | ||
<span>{agent.version}</span> | ||
</Stack> | ||
|
||
<Stack spacing={0.5}> | ||
<span className="font-semibold text-content-primary"> | ||
Server version | ||
</span> | ||
<span>{serverVersion}</span> | ||
</Stack> | ||
<Stack spacing={0.5}> | ||
<span className="font-semibold text-content-primary"> | ||
Agent version | ||
</span> | ||
<span>{agent.version}</span> | ||
</Stack> | ||
|
||
<HelpTooltipLinksGroup> | ||
<HelpTooltipAction | ||
icon={RotateCcwIcon} | ||
onClick={() => { | ||
onUpdate(); | ||
// TODO can we move this tooltip-closing logic to the definition of HelpTooltipAction? | ||
setIsOpen(false); | ||
}} | ||
ariaLabel="Update workspace" | ||
> | ||
Update workspace | ||
</HelpTooltipAction> | ||
</HelpTooltipLinksGroup> | ||
<Stack spacing={0.5}> | ||
<span className="font-semibold text-content-primary"> | ||
Server version | ||
</span> | ||
<span>{serverVersion}</span> | ||
</Stack> | ||
</HelpTooltipContent> | ||
</HelpTooltip> | ||
</TooltipProvider> | ||
|
||
<HelpTooltipLinksGroup> | ||
<HelpTooltipAction | ||
icon={RotateCcwIcon} | ||
onClick={() => { | ||
onUpdate(); | ||
// TODO can we move this tooltip-closing logic to the definition of HelpTooltipAction? | ||
setIsOpen(false); | ||
}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to get some clarity on this comment: was this meant more in the sense of "I'm not sure if it's a good idea to do this", or "I feel like this is a good idea, but I'm not 100% sure how to do it"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit of both, but more the latter. I think whenever a Since Radix doesn't export a component like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, looking at Radix's API docs, I don't see anything that gives direct access to the state that's being contained inside I imagine that if we want to bake that behavior in, we'd basically need to make wrappers over all the Unless we have a bunch of other components wiring that behavior up already, I feel like we can leave things be and wait for more examples to emerge |
||
ariaLabel="Update workspace" | ||
> | ||
Update workspace | ||
</HelpTooltipAction> | ||
</HelpTooltipLinksGroup> | ||
</Stack> | ||
</HelpTooltipContent> | ||
</HelpTooltip> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 0 is probably too fast. what's the default here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default is 700 which feels very long.
Worth mentioning that the MUI popover, which
deprecated/Popover
uses, doesn't use any delay, and I don't think we've added any:coder/site/src/components/deprecated/Popover/Popover.tsx
Lines 130 to 132 in 2030907
so I used a delay of 0 to keep consistency with our current UX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we set it to like, 200? I feel like 0 is intense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, 0 is exactly as intense as prod is rn:
Screen.Recording.2025-09-04.at.4.05.34.PM.mov
I'm so used to 0 delay that 200 feels sluggish to me:
Screen.Recording.2025-09-04.at.4.03.46.PM.mov