test: show error automatically
This commit is contained in:
parent
3019a040d5
commit
d626eaee40
2 changed files with 42 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { Tool, ToolCallState } from "core";
|
||||
import { ComponentType, useContext, useMemo, useState } from "react";
|
||||
import { ComponentType, useContext, useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
ContextItemsPeekItem,
|
||||
openContextItem,
|
||||
|
|
@ -32,6 +32,26 @@ export function SimpleToolCallUI({
|
|||
|
||||
const [open, setOpen] = useState(false);
|
||||
const [showingArgs, setShowingArgs] = useState(false);
|
||||
const hasAutoOpenedError = useRef(false);
|
||||
|
||||
// Auto-open error details when tool call fails
|
||||
useEffect(() => {
|
||||
if (
|
||||
toolCallState.status === "errored" &&
|
||||
shownContextItems.length > 0 &&
|
||||
!hasAutoOpenedError.current
|
||||
) {
|
||||
hasAutoOpenedError.current = true;
|
||||
|
||||
// For single error items, open directly
|
||||
if (shownContextItems.length === 1) {
|
||||
openContextItem(shownContextItems[0], ideMessenger);
|
||||
} else {
|
||||
// For multiple items, expand the view
|
||||
setOpen(true);
|
||||
}
|
||||
}
|
||||
}, [toolCallState.status, shownContextItems, ideMessenger]);
|
||||
|
||||
const args: [string, any][] = useMemo(() => {
|
||||
return Object.entries(toolCallState.parsedArgs);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { Tool, ToolCallState } from "core";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useContext, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { renderContextItems } from "core/util/messageContent";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { ArgsItems, ArgsToggleIcon } from "./ToolCallArgs";
|
||||
import { ToolCallStatusMessage } from "./ToolCallStatusMessage";
|
||||
import { ToolTruncateHistoryIcon } from "./ToolTruncateHistoryIcon";
|
||||
|
|
@ -19,12 +21,30 @@ export function ToolCallDisplay({
|
|||
icon,
|
||||
historyIndex,
|
||||
}: ToolCallDisplayProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [argsExpanded, setArgsExpanded] = useState(false);
|
||||
const hasAutoOpenedError = useRef(false);
|
||||
|
||||
const args: [string, any][] = useMemo(() => {
|
||||
return Object.entries(toolCallState.parsedArgs);
|
||||
}, [toolCallState.parsedArgs]);
|
||||
|
||||
// Auto-open error details when tool call fails
|
||||
useEffect(() => {
|
||||
if (
|
||||
toolCallState.status === "errored" &&
|
||||
toolCallState.output &&
|
||||
toolCallState.output.length > 0 &&
|
||||
!hasAutoOpenedError.current
|
||||
) {
|
||||
hasAutoOpenedError.current = true;
|
||||
ideMessenger.post("showVirtualFile", {
|
||||
name: "Tool Call Error",
|
||||
content: renderContextItems(toolCallState.output),
|
||||
});
|
||||
}
|
||||
}, [toolCallState.status, toolCallState.output, ideMessenger]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col justify-center px-4">
|
||||
<div className="mb-2 flex flex-col">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue