Repository navigation
feat(ToolInvocation): tarjeta plegable para tool calls de IA + ToolInvocationGroup - #43
Merged
Merged
Conversation
…n turno de IA + ToolInvocationGroup Referencia: Vercel AI Elements «Tool» (https://elements.ai-sdk.dev/components/tool), adaptado a @cofoundy/ui: tokens (light/dark), un componente por props, plegado por default, botón Radix con aria-expanded, labels sobreescribibles con defaults en inglés. Acepta la forma real de Fovente (ai_trace.tool_calls[]: tool/args/result_preview, este último JSON truncado a 200 chars). Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Qué es
ToolInvocation: tarjeta plegable que muestra qué hizo una llamada a tool dentro de un turno de IA (nombre legible, resumen de una línea, pill de estado y, plegados, input y output).ToolInvocationGrouppliega varias de un mismo turno detrás de «AI ran N actions». Pedido de André (2026-10-12) para montarlo en Fovente bajo los mensajes de IA conmetadata.ai_trace.tool_calls.API
También se exportan
ToolInvocationStatus,ToolValue,defaultToolInvocationLabels,defaultToolInvocationGroupLabels,toolInvocationVariants,toolInvocationStatusVariantsy los tipos.Lo que mapea de Fovente: cada entrada de
ai_trace.tool_callses{tool, args, result_preview, refused_by?}(backend/src/services/tools/base.py::build_trace_entry), yresult_previewesToolResult.to_json()truncado a 200 chars. Eso queda comoname/input={args}/output={result_preview}; un preview truncado no rompe nada, se muestra como texto. El nombre legible y el resumen los pone quien consume.Referencia de mercado
Vercel AI Elements «Tool», https://elements.ai-sdk.dev/components/tool (fetcheado el 2026-10-12): Tool/ToolHeader/ToolContent/ToolInput/ToolOutput, con estados
input-streaming(Pending) ·input-available(Running) ·output-available(Completed) ·output-error(Error). Lo que cambia acá:approval-*,output-denied) porque hoy no los necesitamos.Diseño, a11y y tokens
--chat-card,--chat-border,--chat-muted,--cf-code-bgy--status-{info,success,error}. No hay hex. Lo revisé en light y en dark.<button>(Radix Collapsible) conaria-expanded/aria-controls, y se abre y cierra con Enter/Space. El estado se lee como texto, no solo por el color.rounded-xlcambia según la app (en Storybook vale 32px).Collapsible, y el spin y el pulse llevanmotion-safe.Story (
Messaging/ToolInvocation)default(plegado) ·open·running·streaming·error-state·truncated-preview(la forma real de prod) ·all-states·localized(labels en español) ·compact·group(un turno con 3 acciones, 1 con error) ·mobile-baseline(375 px).Lo capturé en un Storybook estático local a 720 px en light y dark, y a 375 px en light y dark:
name cotizacionesy el output es un bloque mono con el JSON truncado que termina en «…».scrollWidthigual al viewport), los nombres largos se truncan y la pill queda en solo ícono.Verificación
npx vitest run src/__tests__/components/ToolInvocation.test.tsxtermina con exit 0: 9 tests, que cubren el plegado por default, el teclado, la lista clave/valor, el JSON formateado contra el truncado, el error con role=alert, los labels, el ReactNode y el grupo (conteo, errores, título localizado).npm testda 947 verdes y 3 rojos. Los 3 rojos son los mismos enorigin/mainantes de este PR (ChatInput › should render send button,chat-sim session-lifecycle,chat-sim types-contract.typecheck) y no tienen relación con este cambio.tsc --noEmitda los mismos 3 errores de base demain(ShaderHeroCanvas y los 2 imports aproducts/…de chat-sim), ninguno nuevo.npm run build:iifetermina con exit 0 ynpx storybook buildtambién.