Trivial-conditional cleanup (13 alerts auto-closed): - bashSecurity.ts: remove 3 redundant !inSingleQuote checks - WebFetchTool/UI.tsx, WebSearchTool/UI.tsx: remove redundant guards - theme.ts: simplify getStoredTheme() || defaultTheme - EventStream.tsx: remove dead !replay check - MCPRemoteServerMenu.tsx: remove redundant isAuthenticating - managedEnv.ts: remove dead !env guard - permissionSetup.ts: delete duplicate code block - marketplaceHelpers.ts: simplify blockedValue || undefined - toolExecution.ts: remove dead : '' ternary branch - main.tsx: remove dead dynamicMcpConfig && guard - attachments.ts: wire up suppressNextDiscovery (set flag before await) Also: remove abandoned community gemini (src/services/api/gemini/) and its routing from claude.ts. Upgrade CodeQL to security-and-quality.
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import React from 'react';
|
|
import { MessageResponse } from 'src/components/MessageResponse.js';
|
|
import { TOOL_SUMMARY_MAX_LENGTH } from 'src/constants/toolLimits.js';
|
|
import { Box, Text } from '@anthropic/ink';
|
|
import type { ToolProgressData } from 'src/Tool.js';
|
|
import type { ProgressMessage } from 'src/types/message.js';
|
|
import { formatFileSize, truncate } from 'src/utils/format.js';
|
|
import type { Output } from './WebFetchTool.js';
|
|
|
|
export function renderToolUseMessage(
|
|
{ url, prompt }: Partial<{ url: string; prompt: string }>,
|
|
{ verbose }: { theme?: string; verbose: boolean },
|
|
): React.ReactNode {
|
|
if (!url) {
|
|
return null;
|
|
}
|
|
if (verbose) {
|
|
return `url: "${url}"${prompt ? `, prompt: "${prompt}"` : ''}`;
|
|
}
|
|
return url;
|
|
}
|
|
|
|
export function renderToolUseProgressMessage(): React.ReactNode {
|
|
return (
|
|
<MessageResponse height={1}>
|
|
<Text dimColor>Fetching…</Text>
|
|
</MessageResponse>
|
|
);
|
|
}
|
|
|
|
export function renderToolResultMessage(
|
|
{ bytes, code, codeText, result }: Output,
|
|
_progressMessagesForMessage: ProgressMessage<ToolProgressData>[],
|
|
{ verbose }: { verbose: boolean },
|
|
): React.ReactNode {
|
|
const formattedSize = formatFileSize(bytes);
|
|
if (verbose) {
|
|
return (
|
|
<Box flexDirection="column">
|
|
<MessageResponse height={1}>
|
|
<Text>
|
|
Received <Text bold>{formattedSize}</Text> ({code} {codeText})
|
|
</Text>
|
|
</MessageResponse>
|
|
<Box flexDirection="column">
|
|
<Text>{result}</Text>
|
|
</Box>
|
|
</Box>
|
|
);
|
|
}
|
|
return (
|
|
<MessageResponse height={1}>
|
|
<Text>
|
|
Received <Text bold>{formattedSize}</Text> ({code} {codeText})
|
|
</Text>
|
|
</MessageResponse>
|
|
);
|
|
}
|
|
|
|
export function getToolUseSummary(input: Partial<{ url: string; prompt: string }> | undefined): string | null {
|
|
if (!input?.url) {
|
|
return null;
|
|
}
|
|
return truncate(input.url, TOOL_SUMMARY_MAX_LENGTH);
|
|
}
|