Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11232,6 +11232,7 @@ export default function ChatView(props: ChatViewProps) {
activeThreadEnvironmentId={activeThread.environmentId}
activeThreadId={activeThread.id}
isServerThread={isServerThread}
isRegeneratingTitle={serverThread?.titleRegeneration != null}
activeThreadTitle={activeThread.title}
activeProject={activeProject ?? null}
rightPanelOpen={inlineRightPanelOwnsTitleBar}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";
import { cn } from "~/lib/utils";
import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
import { ProjectEnvironmentBadge } from "./ProjectEnvironmentBadge";
import { TitleSlotRoll } from "./TitleSlotRoll";
import {
buildDraftActionMenuItems,
buildThreadActionMenuItems,
Expand Down Expand Up @@ -1685,10 +1686,9 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
? "text-muted-foreground"
: "text-secondary-label/70",
),
isRegeneratingTitle && "opacity-55",
)}
>
{thread.title}
<TitleSlotRoll regenerating={isRegeneratingTitle}>{thread.title}</TitleSlotRoll>
</span>
);
const accessibleTitle = isRenaming ? null : <span className="sr-only">{thread.title}</span>;
Expand Down
58 changes: 58 additions & 0 deletions apps/web/src/components/TitleSlotRoll.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { useState, type ReactNode } from "react";

import { observeVisibleAnimation } from "~/lib/visibleAnimation";

type Phase = "idle" | "parked" | "rolling" | "landing";

export function TitleSlotRoll({
regenerating,
from,
children,
}: {
regenerating: boolean;
from?: ReactNode;
children: ReactNode;
}) {
const [phase, setPhase] = useState<Phase>(
regenerating ? (from === undefined ? "parked" : "rolling") : "idle",
);
const [outgoing, setOutgoing] = useState(regenerating ? from : undefined);
if (regenerating && (phase === "idle" || phase === "landing")) setPhase("rolling");
if (!regenerating && (phase === "rolling" || phase === "parked")) {
setPhase("landing");
setOutgoing(undefined);
}

if (phase === "idle") return children;

return (
<span className="block overflow-hidden">
<span
className={
phase === "parked"
? "relative block -translate-y-full"
: phase === "rolling"
? "title-slot-roll-out relative block"
: "title-slot-roll-in relative block"
}
onAnimationEnd={(event) => {
if (event.target === event.currentTarget && phase === "landing") setPhase("idle");
}}
>
<span className="block truncate">{outgoing ?? children}</span>
<span
aria-hidden
ref={observeVisibleAnimation}
className="absolute inset-x-0 top-full flex h-full items-center gap-1"
>
<span className="title-slot-dot size-1 rounded-full bg-current" />
<span className="title-slot-dot size-1 rounded-full bg-current" />
<span className="title-slot-dot size-1 rounded-full bg-current" />
</span>
<span aria-hidden className="absolute inset-x-0 top-[200%] block truncate">
{children}
</span>
</span>
</span>
);
}
25 changes: 24 additions & 1 deletion apps/web/src/components/chat/ChatHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { useAtomCommand } from "../../state/use-atom-command";
import { useOrchestrationCommand } from "../../state/use-orchestration-command";
import { readEnvironmentScope, useEnvironmentScope } from "../../state/session";
import { ProjectFavicon } from "../ProjectFavicon";
import { TitleSlotRoll } from "../TitleSlotRoll";
import {
WorkspaceBreadcrumb,
WorkspaceBreadcrumbItem,
Expand All @@ -44,6 +45,7 @@ interface ChatHeaderProps {
activeThreadTitle: string;
/** Drafts have no server thread yet, so the title carries no action menu. */
isServerThread: boolean;
isRegeneratingTitle: boolean;
activeProject: EnvironmentProject | null;
rightPanelOpen: boolean;
onNewThreadInProject: () => void;
Expand Down Expand Up @@ -76,11 +78,22 @@ export const ChatHeader = memo(function ChatHeader({
activeThreadId,
activeThreadTitle,
isServerThread,
isRegeneratingTitle,
activeProject,
rightPanelOpen,
onNewThreadInProject,
onOpenProjectSettings,
}: ChatHeaderProps) {
const [draftTitle, setDraftTitle] = useState(
isServerThread ? undefined : { threadId: activeThreadId, title: activeThreadTitle },
);
if (
!isServerThread &&
(draftTitle?.threadId !== activeThreadId || draftTitle.title !== activeThreadTitle)
) {
setDraftTitle({ threadId: activeThreadId, title: activeThreadTitle });
}
const rollFromTitle = draftTitle?.threadId === activeThreadId ? draftTitle.title : undefined;
const activeProjectName = activeProject?.title;
const activeProjectCwd = activeProject?.workspaceRoot ?? null;
const activeThreadRef = useMemo(
Expand Down Expand Up @@ -124,6 +137,7 @@ export const ChatHeader = memo(function ChatHeader({
)
return;
renameCommittedRef.current = false;
setDraftTitle(undefined);
setRenaming({
environmentId: activeThreadEnvironmentId,
threadId: activeThreadId,
Expand Down Expand Up @@ -333,7 +347,16 @@ export const ChatHeader = memo(function ChatHeader({
}
>
<h2 className="min-w-0">
<WorkspaceBreadcrumbText>{activeThreadTitle}</WorkspaceBreadcrumbText>
<TitleSlotRoll
regenerating={isRegeneratingTitle}
from={
rollFromTitle === undefined ? undefined : (
<WorkspaceBreadcrumbText>{rollFromTitle}</WorkspaceBreadcrumbText>
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
>
<WorkspaceBreadcrumbText>{activeThreadTitle}</WorkspaceBreadcrumbText>
</TitleSlotRoll>
</h2>
<ChevronDownIcon
aria-hidden
Expand Down
62 changes: 62 additions & 0 deletions apps/web/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,68 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
margin-left: var(--live-activity-focus-width);
}

@keyframes title-slot-roll-out {
from {
transform: translateY(0);
}
to {
transform: translateY(-100%);
}
}

@keyframes title-slot-roll-in {
from {
transform: translateY(-100%);
}
to {
transform: translateY(-200%);
}
}

@keyframes title-slot-dot {
0%,
100% {
opacity: 0.3;
}
50% {
opacity: 1;
}
}

@utility title-slot-roll-out {
animation: title-slot-roll-out 400ms cubic-bezier(0.3, 0.8, 0.2, 1) both;

@media (prefers-reduced-motion: reduce) {
animation-duration: 1ms;
}
}

@utility title-slot-roll-in {
animation: title-slot-roll-in 400ms cubic-bezier(0.3, 0.8, 0.2, 1) both;

@media (prefers-reduced-motion: reduce) {
animation-duration: 1ms;
}
}

@utility title-slot-dot {
animation: title-slot-dot 1s ease-in-out infinite;
animation-play-state: var(--visible-animation-state, paused);

&:nth-child(2) {
animation-delay: 150ms;
}

&:nth-child(3) {
animation-delay: 300ms;
}

@media (prefers-reduced-motion: reduce) {
animation: none;
opacity: 0.6;
}
}

@property --assistant-citation-highlight-opacity {
syntax: "<number>";
inherits: true;
Expand Down
Loading