Skip to content

Commit 5998d74

Browse files
committed
Replace mode-toggle titles with styled tooltips
- switch Chat and runtime mode buttons from `title` attributes to Tooltip UI with keyboard hint for plan toggle - use `aria-description` for accessibility text instead of native title tooltips - add default tooltip open/close delays and refresh tooltip popup styling - update browser tests to assert absence of `title` attributes
1 parent 45744cc commit 5998d74

3 files changed

Lines changed: 93 additions & 45 deletions

File tree

‎apps/web/src/components/ChatView.browser.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
814814

815815
try {
816816
const initialModeButton = await waitForInteractionModeButton("Chat");
817-
expect(initialModeButton.title).toContain("enter plan mode");
817+
expect(initialModeButton.getAttribute("title")).toBeNull();
818818

819819
window.dispatchEvent(
820820
new KeyboardEvent("keydown", {
@@ -826,7 +826,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
826826
);
827827
await waitForLayout();
828828

829-
expect((await waitForInteractionModeButton("Chat")).title).toContain("enter plan mode");
829+
expect(await waitForInteractionModeButton("Chat")).toBeTruthy();
830830

831831
const composerEditor = await waitForComposerEditor();
832832
composerEditor.focus();
@@ -841,9 +841,8 @@ describe("ChatView timeline estimator parity (full app)", () => {
841841

842842
await vi.waitFor(
843843
async () => {
844-
expect((await waitForInteractionModeButton("Plan")).title).toContain(
845-
"return to normal chat mode",
846-
);
844+
const planButton = await waitForInteractionModeButton("Plan");
845+
expect(planButton.getAttribute("title")).toBeNull();
847846
},
848847
{ timeout: 8_000, interval: 16 },
849848
);
@@ -859,7 +858,8 @@ describe("ChatView timeline estimator parity (full app)", () => {
859858

860859
await vi.waitFor(
861860
async () => {
862-
expect((await waitForInteractionModeButton("Chat")).title).toContain("enter plan mode");
861+
const chatButton = await waitForInteractionModeButton("Chat");
862+
expect(chatButton.getAttribute("title")).toBeNull();
863863
},
864864
{ timeout: 8_000, interval: 16 },
865865
);

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

Lines changed: 76 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import {
3131
} from "@t3tools/shared/model";
3232
import {
3333
memo,
34+
type ComponentProps,
35+
type ReactNode,
3436
useCallback,
3537
useEffect,
3638
useLayoutEffect,
@@ -251,6 +253,7 @@ function formatWorkingTimer(startIso: string, endIso: string): string | null {
251253
return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;
252254
}
253255

256+
254257
const LAST_EDITOR_KEY = "t3code:last-editor";
255258
const LAST_INVOKED_SCRIPT_BY_PROJECT_KEY = "t3code:last-invoked-script-by-project";
256259
const MAX_VISIBLE_WORK_LOG_ENTRIES = 6;
@@ -3720,49 +3723,85 @@ export default function ChatView({ threadId }: ChatViewProps) {
37203723
<Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" />
37213724

37223725
{/* Interaction mode toggle */}
3723-
<Button
3724-
variant="ghost"
3725-
className="shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80 sm:px-3"
3726-
size="sm"
3727-
type="button"
3728-
onClick={toggleInteractionMode}
3729-
title={
3730-
interactionMode === "plan"
3731-
? "Plan mode — click to return to normal chat mode"
3732-
: "Default mode — click to enter plan mode"
3733-
}
3734-
>
3735-
<BotIcon />
3736-
<span className="sr-only sm:not-sr-only">
3737-
{interactionMode === "plan" ? "Plan" : "Chat"}
3738-
</span>
3739-
</Button>
3726+
<Tooltip>
3727+
<TooltipTrigger
3728+
render={
3729+
<Button
3730+
variant="ghost"
3731+
className="shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80 sm:px-3"
3732+
size="sm"
3733+
type="button"
3734+
onClick={toggleInteractionMode}
3735+
aria-description={
3736+
interactionMode === "plan"
3737+
? "Plan mode — click to return to normal chat mode"
3738+
: "Default mode — click to enter plan mode"
3739+
}
3740+
>
3741+
<BotIcon />
3742+
<span className="sr-only sm:not-sr-only">
3743+
{interactionMode === "plan" ? "Plan" : "Chat"}
3744+
</span>
3745+
</Button>
3746+
}
3747+
/>
3748+
<TooltipPopup
3749+
side="top"
3750+
className="max-w-72 whitespace-normal leading-tight"
3751+
>
3752+
<span className="flex flex-col items-center gap-1">
3753+
<span>
3754+
{interactionMode === "plan"
3755+
? "Plan mode — click to return to normal chat mode"
3756+
: "Default mode — click to enter plan mode"}
3757+
</span>
3758+
<kbd className="inline-flex shrink-0 items-center gap-0.5 rounded bg-foreground/10 px-1 py-0.5 font-medium font-sans text-[10px]">
3759+
<span>⇧</span>
3760+
<span>Tab</span>
3761+
</kbd>
3762+
</span>
3763+
</TooltipPopup>
3764+
</Tooltip>
37403765

37413766
{/* Divider */}
37423767
<Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" />
37433768

37443769
{/* Runtime mode toggle */}
3745-
<Button
3746-
variant="ghost"
3747-
className="shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80 sm:px-3"
3748-
size="sm"
3749-
type="button"
3750-
onClick={() =>
3751-
void handleRuntimeModeChange(
3752-
runtimeMode === "full-access" ? "approval-required" : "full-access",
3753-
)
3754-
}
3755-
title={
3756-
runtimeMode === "full-access"
3770+
<Tooltip>
3771+
<TooltipTrigger
3772+
render={
3773+
<Button
3774+
variant="ghost"
3775+
className="shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80 sm:px-3"
3776+
size="sm"
3777+
type="button"
3778+
onClick={() =>
3779+
void handleRuntimeModeChange(
3780+
runtimeMode === "full-access" ? "approval-required" : "full-access",
3781+
)
3782+
}
3783+
aria-description={
3784+
runtimeMode === "full-access"
3785+
? "Full access — click to require approvals"
3786+
: "Approval required — click for full access"
3787+
}
3788+
>
3789+
{runtimeMode === "full-access" ? <LockOpenIcon /> : <LockIcon />}
3790+
<span className="sr-only sm:not-sr-only">
3791+
{runtimeMode === "full-access" ? "Full access" : "Supervised"}
3792+
</span>
3793+
</Button>
3794+
}
3795+
/>
3796+
<TooltipPopup
3797+
side="top"
3798+
className="max-w-72 whitespace-normal leading-tight"
3799+
>
3800+
{runtimeMode === "full-access"
37573801
? "Full access — click to require approvals"
3758-
: "Approval required — click for full access"
3759-
}
3760-
>
3761-
{runtimeMode === "full-access" ? <LockOpenIcon /> : <LockIcon />}
3762-
<span className="sr-only sm:not-sr-only">
3763-
{runtimeMode === "full-access" ? "Full access" : "Supervised"}
3764-
</span>
3765-
</Button>
3802+
: "Approval required — click for full access"}
3803+
</TooltipPopup>
3804+
</Tooltip>
37663805

37673806
{/* Plan sidebar toggle */}
37683807
{(activePlan || activeProposedPlan || planSidebarOpen) ? (

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ const TooltipProvider = TooltipPrimitive.Provider;
99
const Tooltip = TooltipPrimitive.Root;
1010

1111
function TooltipTrigger(props: TooltipPrimitive.Trigger.Props) {
12-
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
12+
const { delay = 120, closeDelay = 80, ...restProps } = props;
13+
14+
return (
15+
<TooltipPrimitive.Trigger
16+
closeDelay={closeDelay}
17+
data-slot="tooltip-trigger"
18+
delay={delay}
19+
{...restProps}
20+
/>
21+
);
1322
}
1423

1524
function TooltipPopup({
@@ -38,7 +47,7 @@ function TooltipPopup({
3847
>
3948
<TooltipPrimitive.Popup
4049
className={cn(
41-
"relative flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) text-balance rounded-md border bg-popover not-dark:bg-clip-padding text-popover-foreground text-xs shadow-md/5 transition-[width,height,scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-md)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 data-instant:duration-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
50+
"relative flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) text-balance rounded-md border border-border/70 bg-background/95 not-dark:bg-clip-padding text-[11px] font-medium text-foreground/90 shadow-lg/10 shadow-black/15 backdrop-blur-md transition-[width,height,scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-md)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 data-instant:duration-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
4251
className,
4352
)}
4453
data-slot="tooltip-popup"

0 commit comments

Comments
 (0)