Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions apps/web/src/components/chat/ComposerCommandMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import {
UserRoundIcon,
type LucideIcon,
} from "lucide-react";
import { memo, useLayoutEffect, useRef } from "react";
import { memo, useLayoutEffect, useRef, useState } from "react";

import { type ComposerSlashCommand, type ComposerTriggerKind } from "../../composer-logic";
import { cn } from "~/lib/utils";
import { Badge } from "../ui/badge";
import { Command, CommandGroup, CommandItem, CommandList } from "../ui/command";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";
import { PierreEntryIcon } from "./PierreEntryIcon";
import { ProviderInstanceIcon } from "./ProviderInstanceIcon";
Expand Down Expand Up @@ -200,6 +201,15 @@ const ComposerCommandMenuItem = memo(function ComposerCommandMenuItem(props: {
props.triggerKind === "slash-command" && props.item.type === "skill" ? props.item.skill : null;
const pullRequestPresentation =
props.item.type === "pull-request" ? resolvePullRequestState(props.item.pullRequest) : null;
const descriptionRef = useRef<HTMLSpanElement>(null);
const [descriptionTruncated, setDescriptionTruncated] = useState(false);
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- measures the rendered description so only cut-off text gets a tooltip
useLayoutEffect(() => {
const description = descriptionRef.current;
setDescriptionTruncated(
props.isActive && !!description && description.scrollWidth > description.clientWidth,
);
}, [props.isActive]);

return (
<CommandItem
Expand Down Expand Up @@ -263,9 +273,20 @@ const ComposerCommandMenuItem = memo(function ComposerCommandMenuItem(props: {
props.item.label
)}
</span>
<span className="min-w-0 flex-1 truncate text-left text-secondary-label text-xs">
{props.item.description}
</span>
<Tooltip open={descriptionTruncated}>
<TooltipTrigger
tabIndex={-1}
render={
<span
ref={descriptionRef}
className="min-w-0 flex-1 truncate text-left text-secondary-label text-xs"
/>
}
>
{props.item.description}
</TooltipTrigger>
<TooltipPopup>{props.item.description}</TooltipPopup>
</Tooltip>
{skillSourceKind ? (
<SkillSourceBadge
kind={skillSourceKind}
Expand Down
Loading