From 4d66d57fe7e765b16c4b528ec1d39066938d1246 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Tue, 1 Sep 2026 20:04:41 +0800 Subject: [PATCH] feat(chat): pulse the artifact folder when generated files arrive The toolbar count was easy to miss on completed answers. Animate only newly arriving artifacts so history stays still. --- .../components/css/chat-message-shared.less | 49 ++++++++++++++++++- .../composables/useArtifactArriveMotion.ts | 31 ++++++++++++ .../chat/components/AgentStreamDisplay.vue | 5 +- .../answerToolbarCompletion.test.mjs | 7 ++- frontend/src/views/chat/components/botmsg.vue | 5 +- 5 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 frontend/src/composables/useArtifactArriveMotion.ts diff --git a/frontend/src/components/css/chat-message-shared.less b/frontend/src/components/css/chat-message-shared.less index f4d1b314..f6efcd8c 100644 --- a/frontend/src/components/css/chat-message-shared.less +++ b/frontend/src/components/css/chat-message-shared.less @@ -95,6 +95,10 @@ flex-shrink: 0; } +.answer-toolbar__artifact.is-arrived { + animation: artifact-toolbar-arrive 0.7s cubic-bezier(0.22, 1.2, 0.36, 1); +} + .answer-toolbar__artifact.is-collecting .t-button { color: var(--td-text-color-placeholder); cursor: wait; @@ -114,6 +118,20 @@ } } +@keyframes artifact-toolbar-arrive { + 0% { + transform: scale(0.82); + } + + 55% { + transform: scale(1.12); + } + + 100% { + transform: scale(1); + } +} + .answer-toolbar__artifact-count { position: absolute; top: -2px; @@ -127,8 +145,8 @@ height: 14px; padding: 0 3px; border-radius: 7px; - background: var(--td-bg-color-secondarycontainer); - color: var(--td-text-color-secondary); + background: var(--td-brand-color); + color: var(--td-text-color-anti); font-size: 10px; font-weight: 600; line-height: 1; @@ -136,6 +154,33 @@ pointer-events: none; } +.answer-toolbar__artifact.is-arrived .answer-toolbar__artifact-count { + animation: artifact-count-arrive 0.7s cubic-bezier(0.22, 1.4, 0.36, 1); +} + +@keyframes artifact-count-arrive { + 0% { + transform: scale(0.4); + opacity: 0; + } + + 60% { + transform: scale(1.28); + opacity: 1; + } + + 100% { + transform: scale(1); + } +} + +@media (prefers-reduced-motion: reduce) { + .answer-toolbar__artifact.is-arrived, + .answer-toolbar__artifact.is-arrived .answer-toolbar__artifact-count { + animation: none; + } +} + .answer-toolbar__follow-up-loading { display: inline-flex; align-items: center; diff --git a/frontend/src/composables/useArtifactArriveMotion.ts b/frontend/src/composables/useArtifactArriveMotion.ts new file mode 100644 index 00000000..16083925 --- /dev/null +++ b/frontend/src/composables/useArtifactArriveMotion.ts @@ -0,0 +1,31 @@ +import { nextTick, onMounted, ref, watch, type Ref } from 'vue' + +/** + * One-shot attention motion when generated files first land on a live + * answer. Historical messages already have artifacts at mount and stay still. + */ +export function useArtifactArriveMotion(artifactCount: Ref) { + const artifactArrived = ref(false) + let armed = false + + onMounted(() => { + requestAnimationFrame(() => { + armed = true + }) + }) + + watch(artifactCount, (count, previous) => { + if (!armed || count <= 0 || (previous ?? 0) > 0) return + artifactArrived.value = false + nextTick(() => { + artifactArrived.value = true + }) + }) + + function onArtifactArriveEnd(event?: AnimationEvent) { + if (event?.animationName && event.animationName !== 'artifact-toolbar-arrive') return + artifactArrived.value = false + } + + return { artifactArrived, onArtifactArriveEnd } +} diff --git a/frontend/src/views/chat/components/AgentStreamDisplay.vue b/frontend/src/views/chat/components/AgentStreamDisplay.vue index 96e87839..ddd364cd 100644 --- a/frontend/src/views/chat/components/AgentStreamDisplay.vue +++ b/frontend/src/views/chat/components/AgentStreamDisplay.vue @@ -341,7 +341,8 @@ mode is the primary path for skills, so this is where the button is most likely to appear. --> + :class="{ 'is-collecting': artifactButtonCollecting, 'is-arrived': artifactArrived }" + @animationend="onArtifactArriveEnd"> { }); const hasArtifacts = computed(() => artifactList.value.length > 0); const artifactCount = computed(() => artifactList.value.length); +const { artifactArrived, onArtifactArriveEnd } = useArtifactArriveMotion(artifactCount); const artifactsCollecting = computed(() => isCollectingSkillArtifacts(props.session as any)); const artifactButtonCollecting = computed(() => artifactsCollecting.value && !hasArtifacts.value); const sessionIdForArtifacts = computed(() => props.sessionId ?? ''); diff --git a/frontend/src/views/chat/components/answerToolbarCompletion.test.mjs b/frontend/src/views/chat/components/answerToolbarCompletion.test.mjs index 3214c34f..f54cdd49 100644 --- a/frontend/src/views/chat/components/answerToolbarCompletion.test.mjs +++ b/frontend/src/views/chat/components/answerToolbarCompletion.test.mjs @@ -30,7 +30,12 @@ test('artifact count is a top-right overlay instead of t-badge', () => { assert.match(agentStream, /class="answer-toolbar__artifact-count"/) assert.match(sharedStyles, /answer-toolbar__artifact-count/) assert.match(sharedStyles, /position: absolute/) - assert.match(sharedStyles, /td-bg-color-secondarycontainer/) + assert.match(sharedStyles, /td-brand-color/) + assert.match(sharedStyles, /artifact-toolbar-arrive/) + assert.match(botMessage, /is-arrived': artifactArrived/) + assert.match(agentStream, /is-arrived': artifactArrived/) + assert.match(botMessage, /useArtifactArriveMotion/) + assert.match(agentStream, /useArtifactArriveMotion/) assert.doesNotMatch(botMessage, /