fix(webui): align message actions and simplify compaction notices
This commit is contained in:
1 parent
39a817e72d
commit
a3e9d0f9a9
14 files changed
+29
-33
No files matched your search
@@ -304,7 +304,7 @@ function IncomingSessionMessage({
|
|||||||
{createdAtLabel || showCopyAction ? (
|
{createdAtLabel || showCopyAction ? (
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<div
|
<div
|
||||||
className="mt-1 flex min-h-8 items-center gap-1.5 text-muted-foreground"
|
className="message-actions mt-1 flex min-h-8 items-center gap-1.5 text-muted-foreground"
|
||||||
>
|
>
|
||||||
{showCopyAction ? <MessageCopyButton content={message.content} /> : null}
|
{showCopyAction ? <MessageCopyButton content={message.content} /> : null}
|
||||||
{createdAtLabel ? (
|
{createdAtLabel ? (
|
||||||
@@ -530,7 +530,7 @@ export function MessageBubble({
|
|||||||
data-state={showAssistantFooterRow ? "visible" : "reserved"}
|
data-state={showAssistantFooterRow ? "visible" : "reserved"}
|
||||||
aria-hidden={showAssistantFooterRow ? undefined : true}
|
aria-hidden={showAssistantFooterRow ? undefined : true}
|
||||||
className={cn(
|
className={cn(
|
||||||
"mt-2 flex min-h-8 flex-wrap items-center gap-x-2 gap-y-1 text-muted-foreground",
|
"message-actions mt-2 flex min-h-8 flex-wrap items-center gap-x-2 gap-y-1 text-muted-foreground",
|
||||||
"transition-opacity duration-300 ease-out motion-reduce:transition-none",
|
"transition-opacity duration-300 ease-out motion-reduce:transition-none",
|
||||||
showAssistantFooterRow
|
showAssistantFooterRow
|
||||||
? "opacity-100"
|
? "opacity-100"
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Archive, CircleAlert, LoaderCircle } from "lucide-react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
@@ -11,17 +10,12 @@ interface ContextCompactionNoticeProps {
|
|||||||
export function ContextCompactionNotice({ compaction }: ContextCompactionNoticeProps) {
|
export function ContextCompactionNotice({ compaction }: ContextCompactionNoticeProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const title = compaction.phase === "started"
|
const title = compaction.phase === "started"
|
||||||
? t("thread.compaction.started", { defaultValue: "Compressing context…" })
|
? t("thread.compaction.started", { defaultValue: "Compressing context" })
|
||||||
: compaction.phase === "failed"
|
: compaction.phase === "failed"
|
||||||
? t("thread.compaction.failed", { defaultValue: "Context compaction failed" })
|
? t("thread.compaction.failed", { defaultValue: "Context compaction failed" })
|
||||||
: compaction.phase === "cancelled"
|
: compaction.phase === "cancelled"
|
||||||
? t("thread.compaction.cancelled", { defaultValue: "Context compaction cancelled" })
|
? t("thread.compaction.cancelled", { defaultValue: "Context compaction cancelled" })
|
||||||
: t("thread.compaction.succeeded", { defaultValue: "Context compacted" });
|
: t("thread.compaction.succeeded", { defaultValue: "Context compacted" });
|
||||||
const Icon = compaction.phase === "started"
|
|
||||||
? LoaderCircle
|
|
||||||
: compaction.phase === "failed"
|
|
||||||
? CircleAlert
|
|
||||||
: Archive;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -29,23 +23,18 @@ export function ContextCompactionNotice({ compaction }: ContextCompactionNoticeP
|
|||||||
aria-live={compaction.announce ? "polite" : undefined}
|
aria-live={compaction.announce ? "polite" : undefined}
|
||||||
aria-busy={compaction.phase === "started"}
|
aria-busy={compaction.phase === "started"}
|
||||||
data-context-compaction={compaction.phase}
|
data-context-compaction={compaction.phase}
|
||||||
className="mx-auto flex w-full max-w-[49.5rem] items-center gap-2.5 py-1 text-xs text-muted-foreground"
|
className="mx-auto flex w-full max-w-[49.5rem] items-center justify-center gap-3 py-2 text-xs text-muted-foreground"
|
||||||
>
|
>
|
||||||
<span
|
<span aria-hidden className="h-px min-w-4 max-w-16 flex-1 bg-border/60" />
|
||||||
|
<p
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex size-6 shrink-0 items-center justify-center rounded-full bg-muted/60",
|
"min-w-0 text-center leading-5",
|
||||||
compaction.phase === "failed" && "text-destructive",
|
compaction.phase === "failed" && "text-destructive/80",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Icon
|
{title}
|
||||||
className={cn(
|
</p>
|
||||||
"size-3.5",
|
<span aria-hidden className="h-px min-w-4 max-w-16 flex-1 bg-border/60" />
|
||||||
compaction.phase === "started" && "animate-spin motion-reduce:animate-none",
|
|
||||||
)}
|
|
||||||
aria-hidden
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
<p className="min-w-0 font-medium leading-5 text-foreground/80">{title}</p>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -735,7 +735,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-actions > button:first-child {
|
||||||
|
margin-inline-start: -0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
@media (pointer: coarse) {
|
@media (pointer: coarse) {
|
||||||
|
.message-actions > button:first-child {
|
||||||
|
margin-inline-start: -0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
.touch-target {
|
.touch-target {
|
||||||
min-width: 2.75rem;
|
min-width: 2.75rem;
|
||||||
min-height: 2.75rem;
|
min-height: 2.75rem;
|
||||||
|
|||||||
@@ -1387,7 +1387,7 @@
|
|||||||
"compaction": {
|
"compaction": {
|
||||||
"cancelled": "Context compaction cancelled",
|
"cancelled": "Context compaction cancelled",
|
||||||
"empty": "Nothing to compact.",
|
"empty": "Nothing to compact.",
|
||||||
"started": "Compressing context…",
|
"started": "Compressing context",
|
||||||
"failed": "Context compaction failed",
|
"failed": "Context compaction failed",
|
||||||
"succeeded": "Context compacted"
|
"succeeded": "Context compacted"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1188,7 +1188,7 @@
|
|||||||
"compaction": {
|
"compaction": {
|
||||||
"cancelled": "Compresión de contexto cancelada",
|
"cancelled": "Compresión de contexto cancelada",
|
||||||
"empty": "No hay contexto que comprimir.",
|
"empty": "No hay contexto que comprimir.",
|
||||||
"started": "Comprimiendo el contexto…",
|
"started": "Comprimiendo el contexto",
|
||||||
"failed": "La compresión del contexto falló",
|
"failed": "La compresión del contexto falló",
|
||||||
"succeeded": "Contexto comprimido"
|
"succeeded": "Contexto comprimido"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1187,7 +1187,7 @@
|
|||||||
"compaction": {
|
"compaction": {
|
||||||
"cancelled": "Compression du contexte annulée",
|
"cancelled": "Compression du contexte annulée",
|
||||||
"empty": "Aucun contexte à compresser.",
|
"empty": "Aucun contexte à compresser.",
|
||||||
"started": "Compression du contexte…",
|
"started": "Compression du contexte",
|
||||||
"failed": "Échec de la compression du contexte",
|
"failed": "Échec de la compression du contexte",
|
||||||
"succeeded": "Contexte compressé"
|
"succeeded": "Contexte compressé"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1187,7 +1187,7 @@
|
|||||||
"compaction": {
|
"compaction": {
|
||||||
"cancelled": "Pemadatan konteks dibatalkan",
|
"cancelled": "Pemadatan konteks dibatalkan",
|
||||||
"empty": "Tidak ada konteks yang perlu dipadatkan.",
|
"empty": "Tidak ada konteks yang perlu dipadatkan.",
|
||||||
"started": "Memadatkan konteks…",
|
"started": "Memadatkan konteks",
|
||||||
"failed": "Pemadatan konteks gagal",
|
"failed": "Pemadatan konteks gagal",
|
||||||
"succeeded": "Konteks dipadatkan"
|
"succeeded": "Konteks dipadatkan"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1187,7 +1187,7 @@
|
|||||||
"compaction": {
|
"compaction": {
|
||||||
"cancelled": "コンテキストの圧縮をキャンセルしました",
|
"cancelled": "コンテキストの圧縮をキャンセルしました",
|
||||||
"empty": "圧縮するコンテキストはありません。",
|
"empty": "圧縮するコンテキストはありません。",
|
||||||
"started": "コンテキストを圧縮中…",
|
"started": "コンテキストを圧縮中",
|
||||||
"failed": "コンテキストの圧縮に失敗しました",
|
"failed": "コンテキストの圧縮に失敗しました",
|
||||||
"succeeded": "コンテキストを圧縮しました"
|
"succeeded": "コンテキストを圧縮しました"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1187,7 +1187,7 @@
|
|||||||
"compaction": {
|
"compaction": {
|
||||||
"cancelled": "컨텍스트 압축이 취소되었습니다",
|
"cancelled": "컨텍스트 압축이 취소되었습니다",
|
||||||
"empty": "압축할 컨텍스트가 없습니다.",
|
"empty": "압축할 컨텍스트가 없습니다.",
|
||||||
"started": "컨텍스트 압축 중…",
|
"started": "컨텍스트 압축 중",
|
||||||
"failed": "컨텍스트 압축 실패",
|
"failed": "컨텍스트 압축 실패",
|
||||||
"succeeded": "컨텍스트를 압축했습니다"
|
"succeeded": "컨텍스트를 압축했습니다"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1201,7 +1201,7 @@
|
|||||||
"compaction": {
|
"compaction": {
|
||||||
"cancelled": "Compactação do contexto cancelada",
|
"cancelled": "Compactação do contexto cancelada",
|
||||||
"empty": "Não há contexto para compactar.",
|
"empty": "Não há contexto para compactar.",
|
||||||
"started": "Compactando contexto…",
|
"started": "Compactando contexto",
|
||||||
"failed": "Falha ao compactar o contexto",
|
"failed": "Falha ao compactar o contexto",
|
||||||
"succeeded": "Contexto compactado"
|
"succeeded": "Contexto compactado"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1187,7 +1187,7 @@
|
|||||||
"compaction": {
|
"compaction": {
|
||||||
"cancelled": "Đã hủy nén ngữ cảnh",
|
"cancelled": "Đã hủy nén ngữ cảnh",
|
||||||
"empty": "Không có ngữ cảnh cần nén.",
|
"empty": "Không có ngữ cảnh cần nén.",
|
||||||
"started": "Đang nén ngữ cảnh…",
|
"started": "Đang nén ngữ cảnh",
|
||||||
"failed": "Nén ngữ cảnh không thành công",
|
"failed": "Nén ngữ cảnh không thành công",
|
||||||
"succeeded": "Đã nén ngữ cảnh"
|
"succeeded": "Đã nén ngữ cảnh"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1387,7 +1387,7 @@
|
|||||||
"compaction": {
|
"compaction": {
|
||||||
"cancelled": "上下文压缩已取消",
|
"cancelled": "上下文压缩已取消",
|
||||||
"empty": "无需压缩上下文",
|
"empty": "无需压缩上下文",
|
||||||
"started": "正在压缩上下文…",
|
"started": "正在压缩上下文",
|
||||||
"failed": "上下文压缩失败",
|
"failed": "上下文压缩失败",
|
||||||
"succeeded": "上下文已压缩"
|
"succeeded": "上下文已压缩"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1187,7 +1187,7 @@
|
|||||||
"compaction": {
|
"compaction": {
|
||||||
"cancelled": "上下文壓縮已取消",
|
"cancelled": "上下文壓縮已取消",
|
||||||
"empty": "無需壓縮上下文",
|
"empty": "無需壓縮上下文",
|
||||||
"started": "正在壓縮上下文…",
|
"started": "正在壓縮上下文",
|
||||||
"failed": "上下文壓縮失敗",
|
"failed": "上下文壓縮失敗",
|
||||||
"succeeded": "上下文已壓縮"
|
"succeeded": "上下文已壓縮"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -133,7 +133,6 @@ describe("MessageBubble", () => {
|
|||||||
expect(notice).toHaveAttribute("aria-live", "polite");
|
expect(notice).toHaveAttribute("aria-live", "polite");
|
||||||
expect(screen.getByText("Context compacted")).toBeInTheDocument();
|
expect(screen.getByText("Context compacted")).toBeInTheDocument();
|
||||||
expect(notice).toHaveTextContent(/^Context compacted$/);
|
expect(notice).toHaveTextContent(/^Context compacted$/);
|
||||||
expect(notice?.querySelector(".lucide-archive")).toBeInTheDocument();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders user messages as right-aligned pills", () => {
|
it("renders user messages as right-aligned pills", () => {
|
||||||
|
|||||||
Reference in new issue
Block a user