From 72f79f7bd6ee924959011369bb4d79d922466a94 Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Wed, 25 Nov 2026 00:58:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ui):=20=E4=BE=A7=E8=BE=B9=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E7=9A=84=E9=99=84=E4=BB=B6=E4=B8=8E=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=8E=A5=E5=85=A5=E7=BB=9F=E4=B8=80=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SidechatImages:加载态改用 Notice(inline, loading),不可用改用 StatusLine(plain, role=status); 缩略图仍是 blob URL 的 ,行为不变。 - SidechatAttachments:读取失败的占位改用 StatusLine(plain);文件附件从手写 chip 换成 ListRow(leading=FileTypeIcon、title=name、meta=size),外层 span 只保留宽度约束与悬浮 title。 - SideChatView.module.css:删除随之失效的 .sidechatAttachmentFailed / .sidechatAttachmentName / .sidechatAttachmentSize,.sidechatAttachmentFile 收成布局壳。 - 行为、文案、可访问性名称与 data-* 未变;测试断言零改动。 缺口(未在 ui/** 造件,按任务约束只报告):非交互的文件 chip 仍缺共享件, 当前由 SidechatAttachments.FileChip 与 SideChatView.tsx 的附件卡手写两处。 --- src/client/SideChatView.module.css | 34 ++---------------------------- src/client/SidechatAttachments.tsx | 14 +++++++----- src/client/SidechatImages.tsx | 7 +++--- 3 files changed, 15 insertions(+), 40 deletions(-) diff --git a/src/client/SideChatView.module.css b/src/client/SideChatView.module.css index 296ca896..86fafdeb 100644 --- a/src/client/SideChatView.module.css +++ b/src/client/SideChatView.module.css @@ -927,42 +927,12 @@ background: var(--dsw-alias-bg-base); } -/* A declined read is a reader-visible fact, not a broken image: one quiet - * line in the chip's own typography. */ -.sidechatAttachmentFailed { - font-size: var(--dsh-content-font-size-secondary, 13px); - line-height: calc(18px + var(--dsh-content-font-delta-secondary, 0px)); - font-family: var(--dsw-font-family); - color: var(--dsw-alias-label-tertiary); -} - -/* The main conversation's file card: type glyph, name, size. */ +/* A file attachment is the shared list row now; this wrapper only keeps the + * chip's width bounds and the hover tooltip the row's ellipsis needs. */ .sidechatAttachmentFile { display: inline-flex; - align-items: center; - gap: 6px; min-width: 0; max-width: 100%; - padding: 3px 6px; - border: 1px solid var(--dsw-alias-border-l2); - border-radius: 6px; - font-size: var(--dsh-content-font-size-secondary, 13px); - line-height: calc(18px + var(--dsh-content-font-delta-secondary, 0px)); - font-family: var(--dsw-font-family); - color: var(--dsw-alias-label-secondary); -} - -.sidechatAttachmentName { - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - color: var(--dsw-alias-label-primary); -} - -.sidechatAttachmentSize { - flex: none; - color: var(--dsw-alias-label-tertiary); } @keyframes sidechatRowIn { diff --git a/src/client/SidechatAttachments.tsx b/src/client/SidechatAttachments.tsx index 6805632a..b9ee91f3 100644 --- a/src/client/SidechatAttachments.tsx +++ b/src/client/SidechatAttachments.tsx @@ -27,6 +27,7 @@ import type { SidechatImageAttachment, } from './sidechat-transcript.ts' import { t } from './locales.ts' +import { ListRow, StatusLine } from './ui/index.ts' import css from './SideChatView.module.css' /** What one attachment read is currently worth rendering. */ @@ -180,7 +181,7 @@ function AttachmentThumbnail(props: { const { ctx, sessionId, image } = props const state = useAttachmentImage(ctx, sessionId, image) if (state.status === 'failed') { - return {t('sideChatAttachmentImageFailed')} + return } if (state.status !== 'ready') return null return ( @@ -192,14 +193,17 @@ function AttachmentThumbnail(props: { ) } -/** One non-image file: the host's name + size chip, with no byte read. */ +/** One non-image file: the host's name + size row, with no byte read. The + * wrapper keeps the chip's hover tooltip, which the row's own ellipsis needs. */ function FileChip({ file }: { file: SidechatFileAttachment }): React.ReactNode { const size = file.bytes === undefined ? '' : fileSizeText(file.bytes) return ( - - {file.name} - {size === '' ? null : {size}} + } + title={file.name} + {...(size === '' ? {} : { meta: size })} + /> ) } diff --git a/src/client/SidechatImages.tsx b/src/client/SidechatImages.tsx index 8906f5fd..2b5c3de5 100644 --- a/src/client/SidechatImages.tsx +++ b/src/client/SidechatImages.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react' import type { SidechatImageOccurrence } from '../sidechat-images.ts' import { hostRouteUrl } from './host-route-url.ts' import { t } from './locales.ts' +import { Notice, StatusLine } from './ui/index.ts' import css from './SideChatView.module.css' function SavedImage({ childId, messageId, image, visible }: { childId: string; messageId: string; image: SidechatImageOccurrence; visible: boolean }): React.ReactNode { @@ -22,14 +23,14 @@ function SavedImage({ childId, messageId, image, visible }: { childId: string; m }).catch(() => { if (!controller.signal.aborted) setState({ unavailable: true }) }) return () => { controller.abort(); if (url !== undefined) URL.revokeObjectURL(url) } }, [childId, messageId, image.blockIndex, visible]) - if (state === null) return {t('sideChatImageLoading')} - if ('unavailable' in state) return {t('sideChatImageUnavailable')} + if (state === null) return {t('sideChatImageLoading')} + if ('unavailable' in state) return return {image.name { setState({ unavailable: true }) }} /> } export function SidechatImages({ childId, messageId, images, visible }: { childId?: string; messageId?: string; images?: readonly SidechatImageOccurrence[]; visible: boolean }): React.ReactNode { if (images === undefined || images.length === 0) return null return
{images.map(image => childId === undefined || messageId === undefined - ? {t('sideChatImageUnavailable')} + ? : )}
}