From a2799560eb64b942beb97cc19e3c12756e5f3cf2 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Sat, 28 Mar 2026 12:26:23 -0400 Subject: [PATCH] fix: use Popover for context indicator on mobile viewports (#23747) ## Problem The context-usage indicator ring in the agents chat uses a Radix UI `Tooltip`, which only opens on hover. On mobile/touch devices there is no hover event, so tapping the indicator does nothing. ## Fix On mobile viewports (`< 640 px`, matching the existing `isMobileViewport()` helper), render a `Popover` instead of a `Tooltip` so that tapping the ring toggles the context-usage info. Desktop behavior (hover tooltip) is unchanged. - Extract the trigger button and content into shared variables to avoid duplication - Conditionally render `Popover` (mobile) or `Tooltip` (desktop) based on viewport width - Both `Popover` and `PopoverContent` were already imported in the file --- .../AgentsPage/components/AgentChatInput.tsx | 116 ++++++++++-------- 1 file changed, 67 insertions(+), 49 deletions(-) diff --git a/site/src/pages/AgentsPage/components/AgentChatInput.tsx b/site/src/pages/AgentsPage/components/AgentChatInput.tsx index 95bc30e904..44f235e774 100644 --- a/site/src/pages/AgentsPage/components/AgentChatInput.tsx +++ b/site/src/pages/AgentsPage/components/AgentChatInput.tsx @@ -223,57 +223,75 @@ const ContextUsageIndicator: FC<{ usage: AgentContextUsage | null }> = ({ ? `Context usage ${percentLabel}. ${formatTokenCount(usedTokens)} of ${formatTokenCount(contextLimitTokens)} tokens used.` : "Context usage"; + const triggerButton = ( + + ); + + const tooltipContent = ( +
+ {hasPercent + ? `${percentLabel} – ${formatTokenCountCompact(usedTokens)} / ${formatTokenCountCompact(contextLimitTokens)} context used` + : "Context usage unavailable"} + {hasPercent && + usage?.compressionThreshold !== undefined && + usage.compressionThreshold > 0 && ( +
+ Compacts at {usage.compressionThreshold}% +
+ )} +
+ ); + + // On mobile viewports, Radix Tooltip only opens on hover which + // doesn't exist on touch devices. Use a Popover instead so a tap + // toggles the context-usage info. + if (isMobileViewport()) { + return ( + + {triggerButton} + + {tooltipContent} + + + ); + } + return ( - - - - -
- {hasPercent - ? `${percentLabel} – ${formatTokenCountCompact(usedTokens)} / ${formatTokenCountCompact(contextLimitTokens)} context used` - : "Context usage unavailable"} - {hasPercent && - usage?.compressionThreshold !== undefined && - usage.compressionThreshold > 0 && ( -
- Compacts at {usage.compressionThreshold}% -
- )} -
-
+ {triggerButton} + {tooltipContent}
); };