From 506c927a04869d9d2e0bc838ac03626273e0be09 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 22 Aug 2026 20:34:46 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20am=C3=A9lioration=20UX=20mobile=20chat?= =?UTF-8?q?=20agent=20+=20filtrage=20erreurs=20stal=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Filtrage intelligent des erreurs : une erreur Ollama n'est plus affichée si l'agent tourne sur Gemini - Ajout d'un bouton de dismiss sur AgentErrorAlert pour masquer les erreurs stalées - Masquage du AgentViewSwitcher (conversation/exécutions) sur mobile pour simplifier l'UX - Masquage de la sidebar des sessions sur mobile (visible uniquement desktop lg+) - Amélioration du composer avec safe-area-inset-bottom pour iOS/Android - Ajout de classes CSS pour éviter l'overflow horizontal des messages sur mobile - Label 'Erreur récente' au lieu de 'Dernière erreur' pour plus de clarté Co-authored-by: Mathieu JESER --- .../src/components/agents/AgentChatPanel.tsx | 7 ++- .../src/components/agents/AgentChatView.tsx | 16 +++--- .../agents/AgentConversationView.tsx | 3 +- .../src/components/agents/AgentErrorAlert.tsx | 53 +++++++++++++++++-- frontend/src/styles/global.css | 15 ++++++ 5 files changed, 79 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/agents/AgentChatPanel.tsx b/frontend/src/components/agents/AgentChatPanel.tsx index c1f2fc4b19..d9b90c6a4b 100644 --- a/frontend/src/components/agents/AgentChatPanel.tsx +++ b/frontend/src/components/agents/AgentChatPanel.tsx @@ -185,6 +185,8 @@ type Props = { /** Progression live pendant l’envoi (SSE). */ liveSteps?: AgentChatStep[]; liveAssistantText?: string | null; + /** Provider actif actuel (pour filtrer les erreurs non pertinentes) */ + activeRoutingProvider?: string | null; }; export function AgentChatPanel({ @@ -212,6 +214,7 @@ export function AgentChatPanel({ activeSubagentCount = 0, liveSteps = [], liveAssistantText = null, + activeRoutingProvider = null, }: Props) { const scrollRef = useRef(null); const textareaRef = useRef(null); @@ -308,7 +311,7 @@ export function AgentChatPanel({ )} - + {activeSubagentCount > 0 && (
@@ -515,7 +518,7 @@ export function AgentChatPanel({
)} -
+
{error && (
)} - switchView(mode, focusedRunUuid ?? agent.latest_run?.uuid ?? null)} - /> +
{viewMode === 'runs' ? ( diff --git a/frontend/src/components/agents/AgentConversationView.tsx b/frontend/src/components/agents/AgentConversationView.tsx index f39e08936e..dd05fcd174 100644 --- a/frontend/src/components/agents/AgentConversationView.tsx +++ b/frontend/src/components/agents/AgentConversationView.tsx @@ -369,7 +369,7 @@ export function AgentConversationView({ return (
-
diff --git a/frontend/src/components/agents/AgentErrorAlert.tsx b/frontend/src/components/agents/AgentErrorAlert.tsx index f54e5139a1..9213d0fb1a 100644 --- a/frontend/src/components/agents/AgentErrorAlert.tsx +++ b/frontend/src/components/agents/AgentErrorAlert.tsx @@ -1,4 +1,5 @@ -import { AlertCircle } from 'lucide-preact'; +import { AlertCircle, X } from 'lucide-preact'; +import { useState } from 'preact/hooks'; import type { Agent } from '../../lib/domain-api'; import { getAgentErrorMessage } from '../../lib/agent-errors'; import { agentDetailPath } from '../../lib/agent-routes'; @@ -8,12 +9,46 @@ type Props = { agent: Agent; compact?: boolean; onNavigate?: (event: MouseEvent, path: string) => void; + /** Provider actuellement actif (si différent du default agent) */ + activeProvider?: string | null; }; -export function AgentErrorAlert({ agent, compact = false, onNavigate }: Props) { +/** + * Détermine si l'erreur est pertinente pour le contexte actuel. + * Une erreur Ollama n'est pas pertinente si l'agent tourne actuellement sur Gemini. + */ +function isErrorRelevant( + agent: Agent, + activeProvider: string | null | undefined, +): boolean { + const errorMessage = getAgentErrorMessage(agent); + if (!errorMessage) { + return false; + } + + // Si pas de provider actif spécifié, on montre l'erreur + if (!activeProvider) { + return true; + } + + const lower = errorMessage.toLowerCase(); + const isOllamaError = lower.includes('ollama'); + const isGeminiActive = activeProvider === 'gemini' || agent.provider?.provider === 'gemini'; + + // Si l'erreur est Ollama mais que l'agent tourne sur Gemini, on cache l'erreur + if (isOllamaError && isGeminiActive) { + return false; + } + + return true; +} + +export function AgentErrorAlert({ agent, compact = false, onNavigate, activeProvider }: Props) { + const [dismissed, setDismissed] = useState(false); + const message = getAgentErrorMessage(agent); - if (!message) { + if (!message || dismissed || !isErrorRelevant(agent, activeProvider)) { return null; } @@ -26,13 +61,13 @@ export function AgentErrorAlert({ agent, compact = false, onNavigate }: Props) { return ( ); diff --git a/frontend/src/styles/global.css b/frontend/src/styles/global.css index 67391e08a9..664c90dcfb 100644 --- a/frontend/src/styles/global.css +++ b/frontend/src/styles/global.css @@ -658,3 +658,18 @@ input { color: var(--color-error); font-weight: 600; } + +/* Mobile chat improvements: composer always accessible, full-width messages */ +@media (max-width: 640px) { + /* Agent chat composer: safe bottom spacing */ + .agent-chat-composer { + padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); + } + + /* Prevent horizontal overflow on messages */ + .agent-chat-message { + max-width: 100%; + word-wrap: break-word; + overflow-wrap: break-word; + } +}