Skip to content

Commit a66caa6

Browse files
t3dotggclaude
andcommitted
feat(web): show the suggestion's Tab hint as a key
The "⇥ Tab" hint was plain placeholder text and read as part of the suggestion. It now renders in an outlined Kbd after the suggestion. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c4bac06 commit a66caa6

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

‎apps/web/src/components/ComposerPromptEditorTiptap.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
useRef,
4848
useState,
4949
type KeyboardEvent as ReactKeyboardEvent,
50+
type ReactNode,
5051
type RefObject,
5152
} from "react";
5253
import { EditorContent, useEditor } from "@tiptap/react";
@@ -158,6 +159,8 @@ export interface ComposerPromptEditorProps {
158159
skills: ReadonlyArray<ServerProviderSkill>;
159160
disabled: boolean;
160161
placeholder: string;
162+
/** Rendered after the placeholder text, such as a key hint. */
163+
placeholderSuffix?: ReactNode;
161164
ariaLabel?: string | undefined;
162165
suggestionListId?: string | undefined;
163166
activeSuggestionId?: string | undefined;
@@ -946,6 +949,7 @@ function ComposerPromptEditorTiptapInner(
946949
containerClassName,
947950
className,
948951
placeholderClassName,
952+
placeholderSuffix,
949953
onChange,
950954
onVisibleSelectionChange,
951955
onCommandKeyDown,
@@ -1826,6 +1830,7 @@ function ComposerPromptEditorTiptapInner(
18261830
)}
18271831
>
18281832
{placeholder}
1833+
{placeholderSuffix}
18291834
</div>
18301835
) : null}
18311836
</div>

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ import {
258258
resolveProviderSlashCommandsForCwd,
259259
} from "@t3tools/client-runtime/providerSkills";
260260
import { useMediaQuery } from "../../hooks/useMediaQuery";
261+
import { Kbd } from "../ui/kbd";
261262
import { useSoftwareKeyboardOpen } from "../../hooks/useSoftwareKeyboardOpen";
262263
import { useStableCallback } from "../../hooks/useStableCallback";
263264
import { usePanelAnimationSettings } from "../../panelAnimations";
@@ -3451,9 +3452,14 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
34513452
? "Choose a project above to start a thread"
34523453
: showProviderUnavailable
34533454
? "Enable a provider in Settings to send a message"
3454-
: offeredPromptSuggestion !== null
3455-
? `${offeredPromptSuggestion} ⇥ Tab`
3456-
: DEFAULT_COMPOSER_PLACEHOLDER
3455+
: (offeredPromptSuggestion ?? DEFAULT_COMPOSER_PLACEHOLDER)
3456+
}
3457+
placeholderSuffix={
3458+
offeredPromptSuggestion !== null ? (
3459+
<span className="ml-2 inline-flex align-[1px]">
3460+
<Kbd variant="outline">⇥ Tab</Kbd>
3461+
</span>
3462+
) : undefined
34573463
}
34583464
disabled={
34593465
projectSelectionRequired ||

‎apps/web/src/components/ui/kbd.tsx‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@ import type * as React from "react";
22

33
import { cn } from "~/lib/utils";
44

5-
function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
5+
function Kbd({
6+
className,
7+
variant = "default",
8+
...props
9+
}: React.ComponentProps<"kbd"> & {
10+
/** `outline` draws a physical key, so the hint stays distinct inside surrounding text. */
11+
variant?: "default" | "outline";
12+
}) {
613
return (
714
<kbd
815
className={cn(
9-
"pointer-events-none inline-flex h-5 min-w-5 select-none items-center justify-center gap-1 rounded bg-foreground/[0.07] px-1 font-medium font-sans text-muted-foreground text-xs [&_svg:not([class*='size-'])]:size-3",
16+
"pointer-events-none inline-flex h-5 min-w-5 select-none items-center justify-center gap-1 rounded px-1 font-medium font-sans text-muted-foreground text-xs [&_svg:not([class*='size-'])]:size-3",
17+
variant === "outline"
18+
? "border border-b-2 border-foreground/15 px-1.5"
19+
: "bg-foreground/[0.07]",
1020
className,
1121
)}
1222
data-slot="kbd"

0 commit comments

Comments
 (0)