feat: improve web fetch message (#192)
This commit is contained in:
@@ -950,6 +950,14 @@ func (a *Adapter) handleUserMessage(msg *claudecode.CLIMessage, sessionID, opera
|
||||
a.normalizer.NormalizeToolResult(payload, block.Content)
|
||||
}
|
||||
|
||||
// If there's an error, set the error flag on the payload
|
||||
// This ensures the frontend can display error messages properly
|
||||
if payload != nil && block.IsError {
|
||||
if payload.HttpRequest() != nil {
|
||||
payload.HttpRequest().IsError = true
|
||||
}
|
||||
}
|
||||
|
||||
// Determine status
|
||||
status := "complete"
|
||||
if block.IsError {
|
||||
|
||||
@@ -224,6 +224,7 @@ type HttpRequestPayload struct {
|
||||
URL string `json:"url"`
|
||||
Method string `json:"method,omitempty"`
|
||||
Response string `json:"response,omitempty"`
|
||||
IsError bool `json:"is_error,omitempty"`
|
||||
}
|
||||
|
||||
// GenericPayload is the fallback for unrecognized tools.
|
||||
|
||||
@@ -73,9 +73,11 @@ export const ToolCallMessage = memo(function ToolCallMessage({ comment, permissi
|
||||
const title = transformPathsInText(rawTitle, worktreePath);
|
||||
const status = metadata?.status;
|
||||
|
||||
// Get output from normalized payload (generic tools)
|
||||
// Get output from normalized payload (generic tools or http_request)
|
||||
const normalizedGeneric = metadata?.normalized?.generic;
|
||||
const output = normalizedGeneric?.output ?? metadata?.result;
|
||||
const normalizedHttpRequest = metadata?.normalized?.http_request;
|
||||
const output = normalizedHttpRequest?.response ?? normalizedGeneric?.output ?? metadata?.result;
|
||||
const isHttpError = normalizedHttpRequest?.is_error;
|
||||
|
||||
// Permission state
|
||||
const hasPermission = !!permissionMessage;
|
||||
@@ -221,7 +223,8 @@ export const ToolCallMessage = memo(function ToolCallMessage({ comment, permissi
|
||||
{formattedOutput && (
|
||||
<pre className={cn(
|
||||
"text-xs rounded p-2 overflow-x-auto whitespace-pre-wrap max-h-[200px] overflow-y-auto",
|
||||
formattedOutput.isJson ? "bg-muted/30 font-mono text-[11px]" : "bg-muted/30"
|
||||
formattedOutput.isJson ? "bg-muted/30 font-mono text-[11px]" : "bg-muted/30",
|
||||
isHttpError && "text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950/30"
|
||||
)}>
|
||||
{formattedOutput.content}
|
||||
</pre>
|
||||
|
||||
@@ -68,6 +68,13 @@ export type ShellExecPayload = {
|
||||
output?: ShellExecOutput;
|
||||
};
|
||||
|
||||
export type HttpRequestPayload = {
|
||||
url?: string;
|
||||
method?: string;
|
||||
response?: string;
|
||||
is_error?: boolean;
|
||||
};
|
||||
|
||||
export type NormalizedPayload = {
|
||||
kind?: string;
|
||||
subagent_task?: SubagentTaskPayload;
|
||||
@@ -76,6 +83,7 @@ export type NormalizedPayload = {
|
||||
code_search?: CodeSearchPayload;
|
||||
modify_file?: ModifyFilePayload;
|
||||
shell_exec?: ShellExecPayload;
|
||||
http_request?: HttpRequestPayload;
|
||||
};
|
||||
|
||||
export type ToolCallMetadata = {
|
||||
|
||||
Reference in New Issue
Block a user