Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Unify dialog glass and fix composer overlays (#4365)

Julius Marminge4d83436415c0
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 7345823a4..43a1a8756 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -5561,7 +5561,7 @@ function ChatViewContent(props: ChatViewProps) {
ref={attachDraftHeroTransitionGroupRef}
className="chat-composer-horizontal-inset w-full"
>
- <div className="pointer-events-auto relative z-10 isolate">
+ <div className="pointer-events-auto relative z-10">
{isDraftHeroState ? (
<div className="absolute inset-x-0 bottom-full z-0">
<div
@@ -5593,7 +5593,7 @@ function ChatViewContent(props: ChatViewProps) {
}
>
<div className="chat-composer-glass-host mx-auto w-full max-w-3xl rounded-[22px]">
- <div ref={attachDraftHeroComposerAnchorRef} className="relative z-10 isolate">
+ <div ref={attachDraftHeroComposerAnchorRef} className="relative z-10">
<ChatComposer
composerRef={composerRef}
composerDraftTarget={composerDraftTarget}
diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx
index 986dcf0bb..2fc688678 100644
--- a/apps/web/src/components/chat/ChatComposer.tsx
+++ b/apps/web/src/components/chat/ChatComposer.tsx
@@ -26,6 +26,7 @@ import { serializeComposerFileLink } from "@t3tools/shared/composerTrigger";
import { createModelSelection, normalizeModelSlug } from "@t3tools/shared/model";
import {
memo,
+ type ReactNode,
useCallback,
useEffect,
useImperativeHandle,
@@ -34,6 +35,7 @@ import {
useRef,
useState,
} from "react";
+import { createPortal } from "react-dom";
import {
clampCollapsedComposerCursor,
type ComposerTrigger,
@@ -93,6 +95,64 @@ import { buildExpandedImagePreview, type ExpandedImagePreview } from "./Expanded
import { basenameOfPath } from "../../pierre-icons";
import { cn, randomUUID } from "~/lib/utils";
import { Separator } from "../ui/separator";
+
+function ComposerCommandMenuLayer(props: { anchor: HTMLElement | null; children: ReactNode }) {
+ const [position, setPosition] = useState<{
+ bottom: number;
+ left: number;
+ maxHeight: number;
+ width: number;
+ } | null>(null);
+
+ useLayoutEffect(() => {
+ const anchor = props.anchor;
+ if (!anchor) {
+ setPosition(null);
+ return;
+ }
+
+ const updatePosition = () => {
+ const rect = anchor.getBoundingClientRect();
+ setPosition({
+ bottom: window.innerHeight - rect.top + 8,
+ left: rect.left,
+ maxHeight: Math.max(96, rect.top - 24),
+ width: rect.width,
+ });
+ };
+
+ updatePosition();
+ window.addEventListener("resize", updatePosition);
+ window.addEventListener("scroll", updatePosition, true);
+
+ const observer =
+ typeof ResizeObserver === "undefined" ? null : new ResizeObserver(updatePosition);
+ observer?.observe(anchor);
+
+ return () => {
+ observer?.disconnect();
+ window.removeEventListener("resize", updatePosition);
+ window.removeEventListener("scroll", updatePosition, true);
+ };
+ }, [props.anchor]);
+
+ if (!position) return null;
+
+ return createPortal(
+ <div
+ className="pointer-events-auto fixed z-[70]"
+ style={{
+ bottom: position.bottom,
+ left: position.left,
+ maxHeight: position.maxHeight,
+ width: position.width,
+ }}
+ >
+ {props.children}
+ </div>,
+ document.body,
+ );
+}
import { Button } from "../ui/button";
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
@@ -903,6 +963,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
const [isComposerPrimaryActionsCompact, setIsComposerPrimaryActionsCompact] = useState(false);
const [isComposerModelPickerOpen, setIsComposerModelPickerOpen] = useState(false);
const [isComposerFocused, setIsComposerFocused] = useState(false);
+ const [composerMenuAnchor, setComposerMenuAnchor] = useState<HTMLDivElement | null>(null);
const isMobileViewport = useMediaQuery("max-sm");
const isComposerCollapsedMobile =
isMobileViewport && !forceExpandedOnMobile && !isComposerFocused;
@@ -2337,6 +2398,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
) : null}
<div
+ ref={setComposerMenuAnchor}
className={cn(
"relative px-3 pb-2 sm:px-4",
hasComposerHeader ? "pt-2.5 sm:pt-3" : "pt-3.5 sm:pt-4",
@@ -2344,7 +2406,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
)}
>
{composerMenuOpen && !isComposerApprovalState && (
- <div className="absolute inset-x-0 bottom-full z-20 mb-2">
+ <ComposerCommandMenuLayer anchor={composerMenuAnchor}>
<ComposerCommandMenu
items={composerMenuItems}
resolvedTheme={resolvedTheme}
@@ -2359,7 +2421,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
onHighlightedItemChange={onComposerMenuItemHighlighted}
onSelect={onSelectComposerItem}
/>
- </div>
+ </ComposerCommandMenuLayer>
)}
{!isComposerCollapsedMobile &&
diff --git a/apps/web/src/components/ui/alert-dialog.tsx b/apps/web/src/components/ui/alert-dialog.tsx
index 1150abf33..006c3f9e9 100644
--- a/apps/web/src/components/ui/alert-dialog.tsx
+++ b/apps/web/src/components/ui/alert-dialog.tsx
@@ -3,6 +3,11 @@
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog";
import { cn } from "~/lib/utils";
+import {
+ DIALOG_BACKDROP_CLASS,
+ DIALOG_MOBILE_SHEET_CLASS,
+ DIALOG_POPUP_CLASS,
+} from "~/components/ui/dialog-styles";
const AlertDialogCreateHandle = AlertDialogPrimitive.createHandle;
@@ -18,10 +23,7 @@ function AlertDialogBackdrop({ className, ...props }: AlertDialogPrimitive.Backd
return (
<AlertDialogPrimitive.Backdrop
forceRender
- className={cn(
- "dialog-backdrop fixed inset-0 z-50 transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",
- className,
- )}
+ className={cn(DIALOG_BACKDROP_CLASS, className)}
data-slot="alert-dialog-backdrop"
{...props}
/>
@@ -56,9 +58,9 @@ function AlertDialogPopup({
>
<AlertDialogPrimitive.Popup
className={cn(
- "dialog-glass -translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] outline-none transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0",
- bottomStickOnMobile &&
- "max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4",
+ DIALOG_POPUP_CLASS,
+ "row-start-2 max-h-full max-w-lg text-popover-foreground",
+ bottomStickOnMobile && DIALOG_MOBILE_SHEET_CLASS,
className,
)}
data-slot="alert-dialog-popup"
diff --git a/apps/web/src/components/ui/command.tsx b/apps/web/src/components/ui/command.tsx
index 966960141..deb2fbfe8 100644
--- a/apps/web/src/components/ui/command.tsx
+++ b/apps/web/src/components/ui/command.tsx
@@ -15,6 +15,7 @@ import {
AutocompleteList,
AutocompleteSeparator,
} from "~/components/ui/autocomplete";
+import { DIALOG_BACKDROP_CLASS, DIALOG_POPUP_CLASS } from "~/components/ui/dialog-styles";
const CommandDialog = CommandDialogPrimitive.Root;
@@ -29,10 +30,7 @@ function CommandDialogTrigger(props: CommandDialogPrimitive.Trigger.Props) {
function CommandDialogBackdrop({ className, ...props }: CommandDialogPrimitive.Backdrop.Props) {
return (
<CommandDialogPrimitive.Backdrop
- className={cn(
- "dialog-backdrop fixed inset-0 z-50 transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",
- className,
- )}
+ className={cn(DIALOG_BACKDROP_CLASS, className)}
data-slot="command-dialog-backdrop"
{...props}
/>
@@ -66,7 +64,8 @@ function CommandDialogPopup({
<CommandDialogViewport>
<CommandDialogPrimitive.Popup
className={cn(
- "dialog-glass pointer-events-auto -translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-105 min-h-0 w-full min-w-0 max-w-xl scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border text-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] outline-none transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 **:data-[slot=scroll-area-viewport]:data-has-overflow-y:pe-1",
+ DIALOG_POPUP_CLASS,
+ "pointer-events-auto max-h-105 max-w-xl text-foreground **:data-[slot=scroll-area-viewport]:data-has-overflow-y:pe-1",
className,
)}
data-slot="command-dialog-popup"
diff --git a/apps/web/src/components/ui/dialog-styles.ts b/apps/web/src/components/ui/dialog-styles.ts
new file mode 100644
index 000000000..15e9e8880
--- /dev/null
+++ b/apps/web/src/components/ui/dialog-styles.ts
@@ -0,0 +1,10 @@
+const DIALOG_BACKDROP_CLASS =
+ "dialog-backdrop fixed inset-0 z-50 transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0";
+
+const DIALOG_POPUP_CLASS =
+ "dialog-glass -translate-y-[calc(1.25rem*var(--nested-dialogs))] relative flex min-h-0 w-full min-w-0 scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border opacity-[calc(1-0.1*var(--nested-dialogs))] outline-none transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0";
+
+const DIALOG_MOBILE_SHEET_CLASS =
+ "max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4";
+
+export { DIALOG_BACKDROP_CLASS, DIALOG_MOBILE_SHEET_CLASS, DIALOG_POPUP_CLASS };
diff --git a/apps/web/src/components/ui/dialog.tsx b/apps/web/src/components/ui/dialog.tsx
index 636a1ae7e..a96f64880 100644
--- a/apps/web/src/components/ui/dialog.tsx
+++ b/apps/web/src/components/ui/dialog.tsx
@@ -4,6 +4,11 @@ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
import { XIcon } from "lucide-react";
import { cn } from "~/lib/utils";
import { Button } from "~/components/ui/button";
+import {
+ DIALOG_BACKDROP_CLASS,
+ DIALOG_MOBILE_SHEET_CLASS,
+ DIALOG_POPUP_CLASS,
+} from "~/components/ui/dialog-styles";
import { ScrollArea } from "~/components/ui/scroll-area";
const DialogCreateHandle = DialogPrimitive.createHandle;
@@ -24,10 +29,7 @@ function DialogBackdrop({ className, ...props }: DialogPrimitive.Backdrop.Props)
return (
<DialogPrimitive.Backdrop
forceRender
- className={cn(
- "dialog-backdrop fixed inset-0 z-50 transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",
- className,
- )}
+ className={cn(DIALOG_BACKDROP_CLASS, className)}
data-slot="dialog-backdrop"
{...props}
/>
@@ -49,27 +51,25 @@ function DialogViewport({ className, ...props }: DialogPrimitive.Viewport.Props)
function DialogPopup({
className,
- backdropClassName,
children,
showCloseButton = true,
bottomStickOnMobile = true,
...props
}: DialogPrimitive.Popup.Props & {
- backdropClassName?: string;
showCloseButton?: boolean;
bottomStickOnMobile?: boolean;
}) {
return (
<DialogPortal>
- <DialogBackdrop className={backdropClassName} />
+ <DialogBackdrop />
<DialogViewport
className={cn(bottomStickOnMobile && "max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12")}
>
<DialogPrimitive.Popup
className={cn(
- "dialog-glass -translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] outline-none transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0",
- bottomStickOnMobile &&
- "max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4",
+ DIALOG_POPUP_CLASS,
+ "row-start-2 max-h-full max-w-lg text-popover-foreground",
+ bottomStickOnMobile && DIALOG_MOBILE_SHEET_CLASS,
className,
)}
data-slot="dialog-popup"
diff --git a/apps/web/src/index.css b/apps/web/src/index.css
index cc0889690..98035d7a7 100644
--- a/apps/web/src/index.css
+++ b/apps/web/src/index.css
@@ -381,15 +381,15 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--chat-composer-glass-surface: var(--card);
position: relative;
- isolation: isolate;
box-shadow:
0 0 0 1px rgb(0 0 0 / 8%),
0 12px 28px -18px rgb(0 0 0 / 40%);
}
.chat-composer-glass-host::before {
+ pointer-events: none;
position: absolute;
- z-index: -1;
+ z-index: 0;
inset: 0;
border-radius: inherit;
background: color-mix(
@@ -469,7 +469,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
}
.dark .dialog-glass {
- border-color: color-mix(in srgb, var(--color-white) 14%, transparent);
+ border-color: color-mix(in srgb, var(--color-white) 8%, transparent);
box-shadow:
inset 0 1px rgb(255 255 255 / 4%),
0 24px 72px -20px rgb(0 0 0 / 90%);