Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(mobile): hide keyboard-shortcut hints on touch viewports (LFE-11067) (#15328)

Nikita Kabardina93accd92225
diff --git a/web/src/components/nav/in-app-ai-agent-button.tsx b/web/src/components/nav/in-app-ai-agent-button.tsx
index 89b1b69ca5..f1ad7e22c3 100644
--- a/web/src/components/nav/in-app-ai-agent-button.tsx
+++ b/web/src/components/nav/in-app-ai-agent-button.tsx
@@ -74,7 +74,7 @@ export const InAppAiAgentButton = () => {
<BotMessageSquare className="h-4 w-4" />
<span className="hidden sm:inline">Assistant</span>
<KeyboardShortcut
- className="hidden bg-transparent shadow-none md:inline-flex"
+ className="bg-transparent shadow-none"
keys={[
typeof navigator !== "undefined" &&
navigator.userAgent.includes("Mac")
diff --git a/web/src/components/ui/KeyboardShortcut.stories.tsx b/web/src/components/ui/KeyboardShortcut.stories.tsx
new file mode 100644
index 0000000000..cd36ed5dd6
--- /dev/null
+++ b/web/src/components/ui/KeyboardShortcut.stories.tsx
@@ -0,0 +1,27 @@
+import preview from "../../../.storybook/preview";
+import { KeyboardShortcut } from "./keyboard-shortcut";
+
+const meta = preview.meta({
+ component: KeyboardShortcut,
+});
+
+// Hidden below the `md` breakpoint (768px, the same cutoff `useIsMobile`
+// uses) by default: a keyboard-shortcut hint is noise on a touch device with
+// no physical keyboard (LFE-11067). The underlying shortcut still fires there
+// — only this visual chip is gated. Resize the Storybook canvas below 768px
+// to see it disappear (CSS-only; jsdom-based story tests don't apply media
+// queries, so this is only visible when the canvas renders in a real browser).
+export const Default = meta.story({
+ args: {
+ children: "K",
+ },
+});
+
+// Multiple glyphs (e.g. a modifier + a letter) render as separate chips
+// inside the same kbd, joined by a small gap — the "⌘K" / "⌘ Enter" shape
+// used for command-menu and submit hints.
+export const MultipleKeys = meta.story({
+ args: {
+ keys: ["⌘", "Enter"],
+ },
+});
diff --git a/web/src/components/ui/keyboard-shortcut.tsx b/web/src/components/ui/keyboard-shortcut.tsx
index 57933e5a6f..364a8017c8 100644
--- a/web/src/components/ui/keyboard-shortcut.tsx
+++ b/web/src/components/ui/keyboard-shortcut.tsx
@@ -17,7 +17,13 @@ const KeyboardShortcut = React.forwardRef<HTMLElement, KeyboardShortcutProps>(
<kbd
ref={ref}
className={cn(
- "bg-muted text-muted-foreground pointer-events-none inline-flex h-5 min-w-5 items-center justify-center gap-1 rounded-md border px-1.5 font-mono text-[10px] leading-none font-bold shadow-xs select-none",
+ // Hidden below `md` (768px, matches useIsMobile) by default: a
+ // keyboard-shortcut hint is noise on a touch device with no physical
+ // keyboard. This only hides the visual chip — the shortcut's own
+ // keydown handler is untouched, so a Bluetooth keyboard still works.
+ // CSS-only (no useIsMobile()) so SSR'd hints don't hydration-mismatch
+ // or flash on first paint (LFE-11067).
+ "bg-muted text-muted-foreground pointer-events-none hidden h-5 min-w-5 items-center justify-center gap-1 rounded-md border px-1.5 font-mono text-[10px] leading-none font-bold shadow-xs select-none md:inline-flex",
className,
)}
{...props}
diff --git a/web/src/features/comments/CommentList.tsx b/web/src/features/comments/CommentList.tsx
index 930792e493..4afa97f365 100644
--- a/web/src/features/comments/CommentList.tsx
+++ b/web/src/features/comments/CommentList.tsx
@@ -538,7 +538,7 @@ export function CommentList({
)}
{!searchQuery && (
<KeyboardShortcut
- className="absolute top-1/2 right-1 hidden -translate-y-1/2 opacity-50 sm:inline-flex"
+ className="absolute top-1/2 right-1 -translate-y-1/2 opacity-50"
keys={
typeof navigator !== "undefined" &&
navigator.userAgent.includes("Macintosh")
diff --git a/web/src/features/evals/components/code-eval-template-form-body.tsx b/web/src/features/evals/components/code-eval-template-form-body.tsx
index 14ede1660a..fc078aaac2 100644
--- a/web/src/features/evals/components/code-eval-template-form-body.tsx
+++ b/web/src/features/evals/components/code-eval-template-form-body.tsx
@@ -282,7 +282,7 @@ export function CodeEvalTemplateFormBody({
)}
Format
<KeyboardShortcut
- className="ml-2 hidden h-4 sm:inline-flex"
+ className="ml-2 h-4"
keys={
typeof navigator !== "undefined" &&
navigator.userAgent.includes("Macintosh")
diff --git a/web/src/features/scores/components/AnnotationForm.tsx b/web/src/features/scores/components/AnnotationForm.tsx
index 71d77e0d20..78a6380c47 100644
--- a/web/src/features/scores/components/AnnotationForm.tsx
+++ b/web/src/features/scores/components/AnnotationForm.tsx
@@ -1154,7 +1154,7 @@ function InnerAnnotationForm<Target extends ScoreTarget>({
) ?? -1) + 1;
return digit >= 1 &&
digit <= 9 ? (
- <KeyboardShortcut className="ml-0.5 hidden h-3.5 min-w-3.5 px-1 text-[9px] group-focus-within:inline-flex">
+ <KeyboardShortcut className="ml-0.5 h-3.5 min-w-3.5 px-1 text-[9px] md:hidden md:group-focus-within:inline-flex">
{digit}
</KeyboardShortcut>
) : null;
@@ -1231,7 +1231,11 @@ function InnerAnnotationForm<Target extends ScoreTarget>({
/>
</div>
{rowCount > 0 && (
- <div className="text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-1 px-0.5 text-[11px]">
+ // This legend only exists to advertise keyboard shortcuts, so hide
+ // the whole strip on touch viewports rather than just the kbd
+ // chips inside it (LFE-11067) — the shortcuts themselves still
+ // work if a physical keyboard is attached.
+ <div className="text-muted-foreground hidden flex-wrap items-center gap-x-2 gap-y-1 px-0.5 text-[11px] md:flex">
{rowCount > 1 && (
<span className="flex items-center gap-1">
<KeyboardShortcut className="h-4 min-w-4 px-1 text-[9px]">