feat: reveal the failed call from a tool group's failed badge (#12320)

* feat: reveal the failed call from a tool group's failed badge

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep the failed badge's original font

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Guilhem
2026-11-10 22:53:15 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent fecc8a6bfd
commit 0e1464e877
2 changed files with 52 additions and 3 deletions
@@ -17,6 +17,8 @@
labelMore?: string[]
expanded: boolean
onToggle: () => void
/** Called once the body has finished opening, when its contents have their final position. */
onContentShown?: () => void
// A card with nothing to reveal keeps the header inert (no chevron, no
// hover affordance implying a toggle).
toggleable?: boolean
@@ -49,6 +51,7 @@
labelMore,
expanded,
onToggle,
onContentShown,
toggleable = true,
shimmer = false,
settleLabel = false,
@@ -161,6 +164,7 @@
{#if expanded && children}
<div
transition:slide={{ duration: 150 }}
onintroend={onContentShown}
class={twMerge('border border-border-light rounded-md bg-surface p-3', contentClass)}
>
{@render children()}
@@ -6,6 +6,8 @@
import { callFailed, groupHeader, type ToolGroup } from './toolGroups'
import McpServerIcon from '$lib/components/mcp/McpServerIcon.svelte'
import { resolveMcpServerMark } from '$lib/components/mcp/serverMark'
import { Button } from '$lib/components/common'
import { getChatViewHost } from './chatViewHost'
interface Props {
group: ToolGroup
@@ -14,7 +16,30 @@
let { group, entry }: Props = $props()
const chatHost = getChatViewHost()
let expanded = $state(false)
const rows: Record<number, HTMLElement> = {}
let scrollOnceOpen = false
function scrollToFailedCall() {
const failed = group.entries.find((e) => e.message.role === 'tool' && callFailed(e.message))
if (failed) {
// Here rather than at the click: while the group opens above a chat pinned to its end,
// scroll anchoring keeps it at the end, and that scroll turns automatic scroll back on.
chatHost.disableAutomaticScroll()
rows[failed.index]?.scrollIntoView({ block: 'center' })
}
}
function revealFailedCall() {
if (expanded) {
scrollToFailedCall()
} else {
scrollOnceOpen = true
expanded = true
}
}
const calls = $derived(
group.entries.map((e) => e.message).filter((m): m is ToolDisplayMessage => m.role === 'tool')
@@ -59,7 +84,16 @@
{#snippet status()}
<div class="flex items-center gap-2 shrink-0">
{#if failedCount > 0}
<span class="font-main text-2xs text-red-600 dark:text-red-400">{failedCount} failed</span>
<Button
variant="subtle"
unifiedSize="2xs"
destructive
btnClasses="font-main text-2xs text-red-600 dark:text-red-400 hover:bg-red-100 hover:text-red-800 dark:hover:bg-red-700/40 dark:hover:text-red-100"
title="Show the failed call"
onClick={revealFailedCall}
>
{failedCount} failed
</Button>
{/if}
{#if previewCard}
<ToolPreviewCard card={previewCard} />
@@ -72,7 +106,16 @@
label={header.label}
labelMore={header.more}
{expanded}
onToggle={() => (expanded = !expanded)}
onToggle={() => {
scrollOnceOpen = false
expanded = !expanded
}}
onContentShown={() => {
if (scrollOnceOpen) {
scrollOnceOpen = false
scrollToFailedCall()
}
}}
shimmer={running}
settleLabel
{liveLine}
@@ -83,6 +126,8 @@
contentClass="border-0 border-l rounded-none bg-transparent p-0 pl-2 ml-1.5 mt-0.5"
>
{#each group.entries as { message, index } (index)}
{@render entry(message, index)}
<div bind:this={rows[index]}>
{@render entry(message, index)}
</div>
{/each}
</ChatCollapsibleCard>