feat(webui): refine composer action feedback (#6419)
* feat(webui): refine composer action feedback * fix(webui): preserve composer hit targets and ring previews
This commit is contained in:
1 parent
03e9b5430b
commit
6d4add200b
20 files changed
+351
-48
No files matched your search
@@ -49,6 +49,7 @@ import {
|
||||
import { MAX_WORKBENCH_PANES } from "@/components/workbench/workbench-model";
|
||||
import { SidebarTopicRename } from "@/components/SidebarTopicRename";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { LoadingRing } from "@/components/ui/loading-ring";
|
||||
import {
|
||||
SIDEBAR_SELECTION_ITEM_CLASS,
|
||||
SidebarSelectionHighlight,
|
||||
@@ -1880,12 +1881,6 @@ function ChatsFoldFooter({
|
||||
);
|
||||
}
|
||||
|
||||
function synchronizeRunningRing(element: SVGCircleElement | null) {
|
||||
if (!element) return;
|
||||
// Align pending animations before their first frame, not only after animationstart.
|
||||
for (const animation of element.getAnimations()) animation.startTime = 0;
|
||||
}
|
||||
|
||||
function SessionActivityIndicator({
|
||||
state,
|
||||
}: {
|
||||
@@ -1919,18 +1914,7 @@ function SessionActivityIndicator({
|
||||
aria-label={label}
|
||||
className="grid h-4 w-4 shrink-0 place-items-center"
|
||||
>
|
||||
<svg
|
||||
className="h-3 w-3 text-sidebar-muted-foreground"
|
||||
viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" aria-hidden="true"
|
||||
>
|
||||
<circle cx="12" cy="12" r="10" opacity="0.2" />
|
||||
<circle
|
||||
cx="12" cy="12" r="10" strokeDasharray="16 46.8" strokeLinecap="round"
|
||||
className="sidebar-running-ring"
|
||||
ref={synchronizeRunningRing}
|
||||
onAnimationStart={(event) => synchronizeRunningRing(event.currentTarget)}
|
||||
/>
|
||||
</svg>
|
||||
<LoadingRing className="h-3 w-3 text-sidebar-muted-foreground" />
|
||||
</span>
|
||||
</HoverHint>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { ModelsIcon, StopIcon } from "@/components/icons/product-icons";
|
||||
import { LoadingRing } from "@/components/ui/loading-ring";
|
||||
|
||||
export type ComposerActionState = "voice" | "recording" | "busy" | "stop" | "setup" | "send";
|
||||
|
||||
export function ComposerActionIcon({ state }: { state: ComposerActionState }) {
|
||||
return (
|
||||
<span className="composer-action-icons pointer-events-none relative block h-7 w-7 shrink-0" data-state={state} aria-hidden="true">
|
||||
<span className="composer-action-glyph" data-action-icon="voice" data-active={state === "voice" || undefined}>
|
||||
<svg className="h-6 w-6" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
<rect x="9.5" y="4.75" width="5" height="9.5" rx="2.5" fill="currentColor" />
|
||||
<path d="M7 11.25v.5a5 5 0 0 0 10 0v-.5M12 16.75v2.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
</svg>
|
||||
</span>
|
||||
<span className="composer-action-glyph" data-action-icon="send" data-active={state === "send" || undefined}>
|
||||
<svg className="h-6 w-6" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
<path d="m8.25 10.25 3.75-3.75 3.75 3.75M12 7v10.5" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" />
|
||||
</svg>
|
||||
</span>
|
||||
<span className="composer-action-glyph" data-action-icon="stop" data-active={state === "stop" || undefined}>
|
||||
<LoadingRing track={false} strokeDasharray="12 50.8" className="absolute h-6 w-6 text-foreground/50" strokeWidth="1.5" />
|
||||
<svg className="h-6 w-6" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
||||
<rect x="8" y="8" width="8" height="8" rx="1.75" />
|
||||
</svg>
|
||||
</span>
|
||||
<span className="composer-action-glyph" data-action-icon="recording" data-active={state === "recording" || undefined}>
|
||||
<StopIcon className="h-3.5 w-3.5" fill="currentColor" />
|
||||
</span>
|
||||
<span className="composer-action-glyph" data-action-icon="busy" data-active={state === "busy" || undefined}>
|
||||
<LoadingRing className="h-4 w-4" />
|
||||
</span>
|
||||
<span className="composer-action-glyph" data-action-icon="setup" data-active={state === "setup" || undefined}>
|
||||
<ModelsIcon className="h-4 w-4" />
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
HelpIcon,
|
||||
HistoryIcon,
|
||||
ConversationIcon,
|
||||
VoiceIcon,
|
||||
AttachIcon,
|
||||
RestartIcon,
|
||||
RestrictedAccessIcon,
|
||||
@@ -53,7 +52,6 @@ import {
|
||||
} from "@/lib/composer-mention-text";
|
||||
import { INLINE_TOKEN_HIGHLIGHT_COLOR } from "@/components/InlineTokenHighlight";
|
||||
import {
|
||||
ArrowUp,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
CornerDownRight,
|
||||
@@ -69,6 +67,7 @@ import {
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ComposerActionIcon, type ComposerActionState } from "@/components/thread/ComposerActionIcon";
|
||||
import {
|
||||
floatingItemClassName,
|
||||
floatingItemFocusClassName,
|
||||
@@ -2480,6 +2479,9 @@ export function ThreadComposer({
|
||||
: t("thread.composer.voice.hint");
|
||||
// Touch users need an explicit send action; keep Stop while sending is unavailable.
|
||||
const showStopButton = isStreaming && !!onStop && !canSend;
|
||||
const actionState: ComposerActionState = showVoiceButton
|
||||
? voiceRecorder.state === "transcribing" ? "busy" : voiceRecorder.isRecording ? "recording" : "voice"
|
||||
: showStopButton ? "stop" : modelNeedsSetup ? "setup" : canSend || !isStreaming ? "send" : "busy";
|
||||
const relaxedHeroInput = isHero && images.length === 0 && !isStreaming;
|
||||
const compactIdle = compactWhenIdle && !compactControls && !isHero && !composerFocused
|
||||
&& value.length === 0 && images.length === 0 && !inlineError
|
||||
@@ -2864,31 +2866,18 @@ export function ThreadComposer({
|
||||
}}
|
||||
onClick={showVoiceButton ? voiceRecorder.handleClick : showStopButton ? handleStop : modelNeedsSetup ? onModelBadgeClick : undefined}
|
||||
className={cn(
|
||||
"thread-composer-action thread-composer-round-action touch-target rounded-full",
|
||||
showStopButton && !showVoiceButton
|
||||
? "border border-border/70 bg-card text-foreground/85 hover:text-foreground disabled:text-muted-foreground/50"
|
||||
: "border border-foreground bg-foreground text-background disabled:border-foreground disabled:bg-foreground disabled:text-background",
|
||||
showVoiceButton && voiceRecorder.isRecording && "border-red-500 bg-red-500 text-white hover:bg-red-500 hover:text-white",
|
||||
"composer-primary-action thread-composer-action thread-composer-round-action touch-target rounded-full bg-clip-padding",
|
||||
actionState === "stop"
|
||||
? "border border-transparent bg-foreground/[0.045] text-foreground/85 hover:bg-foreground/[0.08] hover:text-foreground disabled:text-muted-foreground/50"
|
||||
: actionState === "voice"
|
||||
? "border border-transparent bg-foreground/75 text-background hover:bg-foreground/[0.85] hover:text-background disabled:bg-foreground/[0.12] disabled:text-muted-foreground"
|
||||
: "border border-transparent bg-foreground text-background hover:bg-foreground/90 hover:text-background disabled:border-foreground disabled:bg-foreground disabled:text-background",
|
||||
actionState === "send" && "disabled:border-transparent disabled:bg-foreground/[0.12] disabled:text-muted-foreground",
|
||||
showVoiceButton && voiceRecorder.isRecording && "border-transparent bg-red-500 text-white hover:bg-red-500 hover:text-white",
|
||||
isHero ? "h-8 w-8" : "h-9 w-9",
|
||||
)}
|
||||
>
|
||||
{showVoiceButton ? (
|
||||
voiceRecorder.state === "transcribing" ? (
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
) : voiceRecorder.isRecording ? (
|
||||
<StopIcon className="h-3.5 w-3.5" fill="currentColor" />
|
||||
) : (
|
||||
<VoiceIcon className="h-4 w-4" />
|
||||
)
|
||||
) : showStopButton ? (
|
||||
<StopIcon className={cn("fill-current stroke-current", isHero ? "h-3 w-3" : "h-3.5 w-3.5")} />
|
||||
) : modelNeedsSetup ? (
|
||||
<ModelsIcon className="h-4 w-4" />
|
||||
) : canSend || !isStreaming ? (
|
||||
<ArrowUp className="h-4 w-4" />
|
||||
) : (
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
)}
|
||||
<ComposerActionIcon state={actionState} />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
{showVoiceButton ? (
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { SVGProps } from "react";
|
||||
|
||||
function synchronizeRing(element: SVGCircleElement | null) {
|
||||
if (!element) return;
|
||||
// Align the first frame and animations restarted by a live motion preference change.
|
||||
for (const animation of element.getAnimations()) animation.startTime = 0;
|
||||
}
|
||||
|
||||
export function LoadingRing({ track = true, strokeDasharray = "16 46.8", ...props }: SVGProps<SVGSVGElement> & { track?: boolean }) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" aria-hidden="true" {...props}>
|
||||
{track ? <circle cx="12" cy="12" r="10" opacity="0.2" /> : null}
|
||||
<circle
|
||||
cx="12" cy="12" r="10" strokeDasharray={strokeDasharray} strokeLinecap="round"
|
||||
className="loading-ring-arc"
|
||||
ref={synchronizeRing}
|
||||
onAnimationStart={(event) => synchronizeRing(event.currentTarget)}
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import { HoverHint, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Tr
|
||||
import { Disclosure } from "@/components/ui/disclosure";
|
||||
import { ExpandableText } from "@/components/ui/expandable-text";
|
||||
import { StreamingLabelSheen } from "@/components/ui/streaming-label-sheen";
|
||||
import { LoadingRing } from "@/components/ui/loading-ring";
|
||||
import { ImageViewport } from "@/components/ui/image-viewport";
|
||||
import { Sample, type ComponentExample } from "./example";
|
||||
import { useGalleryTranslation } from "./i18n";
|
||||
@@ -302,6 +303,13 @@ export const foundationExamples: ComponentExample[] = [
|
||||
{ title: "controls.imageViewport.title", files: ["image-viewport"], Preview: ImageViewports,
|
||||
description: "controls.imageViewport.description", options: "controls.imageViewport.options",
|
||||
code: '<div className="flex h-80 flex-col"><ImageViewport src={url} alt={label} className="flex-1" /></div>' },
|
||||
{ title: "controls.loadingRing.title", files: ["loading-ring"],
|
||||
Preview: () => <div className="flex items-center gap-6 text-muted-foreground">
|
||||
<LoadingRing className="h-3 w-3" />
|
||||
<LoadingRing track={false} strokeWidth="1.5" strokeDasharray="12 50.8" className="h-6 w-6" />
|
||||
</div>,
|
||||
description: "controls.loadingRing.description", options: "controls.loadingRing.options",
|
||||
code: '<LoadingRing className="h-3 w-3 text-muted-foreground" />\n<LoadingRing track={false} strokeWidth="1.5" strokeDasharray="12 50.8" className="h-6 w-6" />' },
|
||||
{ title: "controls.streaming.title", files: ["streaming-label-sheen"], Preview: StreamingLabels,
|
||||
description: "controls.streaming.description", options: "controls.streaming.options",
|
||||
code: '<StreamingLabelSheen active={running}>Working…</StreamingLabelSheen>' },
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Image-local fit, zoom, pan and pinch controls.",
|
||||
"options": "Supply a bounded className and remount for a different image identity. Set panWithArrows=false when a gallery owns arrow navigation."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Loading ring",
|
||||
"description": "A shared activity ring with an optional track.",
|
||||
"options": "className sets size and color. track=false hides the track; strokeWidth and strokeDasharray adjust the arc. Respects reduced-motion settings."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Animated labels",
|
||||
"description": "A shared text animation for active thinking and tool labels.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Ajuste, zoom, desplazamiento y pellizco propios de cada imagen.",
|
||||
"options": "Proporciona una className con límites y vuelve a montar si cambia la identidad de la imagen. Usa panWithArrows=false cuando una galería gestione las flechas."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Anillo de actividad",
|
||||
"description": "Un indicador de actividad compartido con pista opcional.",
|
||||
"options": "className define el tamaño y el color. track=false oculta la pista; strokeWidth y strokeDasharray ajustan el arco. Respeta la preferencia de movimiento reducido."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Etiquetas animadas",
|
||||
"description": "Una animación de texto compartida para la reflexión activa y las etiquetas de herramientas.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Commandes d’ajustement, zoom, déplacement et pincement propres à l’image.",
|
||||
"options": "Fournissez une className délimitant la zone et remontez le composant si l’identité de l’image change. Définissez panWithArrows=false si une galerie gère les flèches."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Anneau d’activité",
|
||||
"description": "Un indicateur d’activité partagé avec une piste facultative.",
|
||||
"options": "className définit la taille et la couleur. track=false masque la piste ; strokeWidth et strokeDasharray ajustent l’arc. Respecte la préférence de réduction des animations."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Libellés animés",
|
||||
"description": "Une animation de texte partagée pour la réflexion et les libellés d’outils actifs.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Kontrol penyesuaian, zoom, geser, dan cubit untuk setiap gambar.",
|
||||
"options": "Sediakan className dengan batas area dan pasang ulang untuk identitas gambar yang berbeda. Atur panWithArrows=false jika galeri mengelola navigasi panah."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Cincin aktivitas",
|
||||
"description": "Indikator aktivitas bersama dengan jalur opsional.",
|
||||
"options": "className mengatur ukuran dan warna. track=false menyembunyikan jalur; strokeWidth dan strokeDasharray mengatur busur. Mengikuti preferensi pengurangan gerakan."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Label beranimasi",
|
||||
"description": "Animasi teks bersama untuk proses berpikir aktif dan label alat.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "画像単位のフィット、ズーム、移動、ピンチ操作。",
|
||||
"options": "className で領域を制限し、画像の識別情報が変わったら再マウントします。ギャラリーが矢印キー操作を管理する場合は panWithArrows=false にします。"
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "処理リング",
|
||||
"description": "背景リングを省略できる共通の処理インジケーター。",
|
||||
"options": "className でサイズと色を設定します。track=false で背景リングを非表示にし、strokeWidth と strokeDasharray で円弧を調整します。視差効果を減らす設定に従います。"
|
||||
},
|
||||
"streaming": {
|
||||
"title": "アニメーションラベル",
|
||||
"description": "思考中や実行中のツールラベルで共有するテキストアニメーション。",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "이미지별 맞춤, 확대/축소, 이동, 핀치 컨트롤입니다.",
|
||||
"options": "className으로 영역을 제한하고 이미지 식별 정보가 달라지면 다시 마운트합니다. 갤러리가 방향키 탐색을 관리하면 panWithArrows=false로 설정합니다."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "진행 링",
|
||||
"description": "배경 링을 선택적으로 표시하는 공용 진행 표시기입니다.",
|
||||
"options": "className으로 크기와 색상을 설정합니다. track=false는 배경 링을 숨기고, strokeWidth와 strokeDasharray는 호를 조절합니다. 동작 줄이기 설정을 따릅니다."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "애니메이션 레이블",
|
||||
"description": "진행 중인 사고와 도구 레이블이 공유하는 텍스트 애니메이션입니다.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Controles de ajuste, zoom, deslocamento e pinça locais à imagem.",
|
||||
"options": "Forneça uma className com limites e remonte o componente se a identidade da imagem mudar. Use panWithArrows=false quando uma galeria gerenciar as setas."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Anel de atividade",
|
||||
"description": "Um indicador de atividade compartilhado com trilha opcional.",
|
||||
"options": "className define o tamanho e a cor. track=false oculta a trilha; strokeWidth e strokeDasharray ajustam o arco. Respeita a preferência por movimento reduzido."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Rótulos animados",
|
||||
"description": "Uma animação de texto compartilhada para raciocínio ativo e rótulos de ferramentas.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Điều khiển vừa khung, thu phóng, di chuyển và chụm ngón cho từng ảnh.",
|
||||
"options": "Dùng className để giới hạn vùng và gắn kết lại khi danh tính ảnh thay đổi. Đặt panWithArrows=false nếu thư viện ảnh quản lý điều hướng bằng phím mũi tên."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Vòng hoạt động",
|
||||
"description": "Chỉ báo hoạt động dùng chung với vòng nền tùy chọn.",
|
||||
"options": "className đặt kích thước và màu sắc. track=false ẩn vòng nền; strokeWidth và strokeDasharray điều chỉnh cung tròn. Tuân theo tùy chọn giảm chuyển động."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Nhãn động",
|
||||
"description": "Hiệu ứng văn bản dùng chung cho trạng thái suy nghĩ và nhãn công cụ đang hoạt động.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "单张图片的适应、缩放、平移与双指缩放控件。",
|
||||
"options": "用 className 限定边界;更换图片身份时重新挂载。图库管理方向键导航时设置 panWithArrows=false。"
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "运行圆环",
|
||||
"description": "可选底环的共享运行指示器。",
|
||||
"options": "className 设置尺寸和颜色。track=false 隐藏底环;strokeWidth 和 strokeDasharray 调整圆弧。遵循减少动态效果设置。"
|
||||
},
|
||||
"streaming": {
|
||||
"title": "流光文字",
|
||||
"description": "思考中与工具标签共用的文字动画。",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "單張圖片的適應、縮放、平移與雙指縮放。",
|
||||
"options": "用 className 限定邊界;更換圖片身分時重新掛載。圖庫管理方向鍵導覽時設定 panWithArrows=false。"
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "執行圓環",
|
||||
"description": "可選底環的共用執行指示器。",
|
||||
"options": "className 設定尺寸和顏色。track=false 隱藏底環;strokeWidth 和 strokeDasharray 調整圓弧。遵循減少動態效果設定。"
|
||||
},
|
||||
"streaming": {
|
||||
"title": "流光文字",
|
||||
"description": "思考中與工具標籤共用的文字動畫。",
|
||||
|
||||
+43
-4
@@ -1054,17 +1054,56 @@
|
||||
}
|
||||
|
||||
/* loading.dev Ring, Copyright (c) 2026 Jakub Krehel (MIT); THIRD_PARTY_NOTICES.md. */
|
||||
.sidebar-running-ring {
|
||||
.loading-ring-arc {
|
||||
transform-origin: center;
|
||||
animation: sidebar-running-ring 800ms linear infinite;
|
||||
animation: loading-ring-spin 800ms linear infinite;
|
||||
}
|
||||
@keyframes sidebar-running-ring {
|
||||
@keyframes loading-ring-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.composer-primary-action {
|
||||
transition: color 160ms ease-out, background-color 160ms ease-out, border-color 160ms ease-out;
|
||||
}
|
||||
.composer-action-icons {
|
||||
transition: transform 120ms ease-out;
|
||||
}
|
||||
.composer-primary-action:active:not(:disabled) .composer-action-icons {
|
||||
transform: scale(0.94);
|
||||
}
|
||||
.composer-action-glyph {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
opacity: 0;
|
||||
transform: scale(0.72);
|
||||
transition: opacity 140ms ease-out, transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
}
|
||||
.composer-action-glyph[data-active] {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
.composer-action-icons[data-state="stop"] [data-action-icon="send"] {
|
||||
transform: translateY(-3px) scale(0.8);
|
||||
}
|
||||
.composer-action-glyph:not([data-active]) .loading-ring-arc {
|
||||
animation: none;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.sidebar-running-ring {
|
||||
.loading-ring-arc {
|
||||
animation: none;
|
||||
}
|
||||
.composer-primary-action,
|
||||
.composer-action-icons,
|
||||
.composer-primary-action:active:not(:disabled) .composer-action-icons {
|
||||
transition: none;
|
||||
transform: none;
|
||||
}
|
||||
.composer-action-icons[data-state] .composer-action-glyph {
|
||||
transform: none;
|
||||
transition: opacity 80ms linear;
|
||||
}
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
|
||||
Reference in new issue
Block a user