feat: 完成第二版类型清理

This commit is contained in:
claude-code-best committed 2026-03-31 23:03:47 +08:00
1 parent 4c0a655a1c
commit d7a729ca68
604 files changed
+595 -953

No files matched your search

+9 -10
View File
@@ -18,7 +18,7 @@ import type { Screen } from '../screens/REPL.js';
import type { Tools } from '../Tool.js';
import { findToolByName } from '../Tool.js';
import type { AgentDefinitionsResult } from '../tools/AgentTool/loadAgentsDir.js';
import type { Message as MessageType, NormalizedMessage, ProgressMessage as ProgressMessageType, RenderableMessage } from '../types/message.js';
import type { AssistantMessage, AttachmentMessage, Message as MessageType, NormalizedMessage, ProgressMessage as ProgressMessageType, RenderableMessage, SystemMessage, UserMessage } from '../types/message.js';
import { type AdvisorBlock, isAdvisorBlock } from '../utils/advisor.js';
import { collapseBackgroundBashNotifications } from '../utils/collapseBackgroundBashNotifications.js';
import { collapseHookSummaries } from '../utils/collapseHookSummaries.js';
@@ -501,7 +501,7 @@ const MessagesImpl = ({
// null (hook_success, hook_additional_context, hook_cancelled, etc.)
// BEFORE counting/slicing so they don't inflate the "N messages"
// count in ctrl-o or consume slots in the 200-message render cap.
.filter(msg_3 => !isNullRenderingAttachment(msg_3)).filter(_ => shouldShowUserMessage(_, isTranscriptMode)), syntheticStreamingToolUseMessages);
.filter(msg_3 => !isNullRenderingAttachment(msg_3)).filter(_ => shouldShowUserMessage(_, isTranscriptMode)) as (UserMessage | AssistantMessage | AttachmentMessage | SystemMessage)[], syntheticStreamingToolUseMessages);
// Three-tier filtering. Transcript mode (ctrl+o screen) is truly unfiltered.
// Brief-only: SendUserMessage + user input only. Default: drop redundant
// assistant text in turns where SendUserMessage was called (the model's
@@ -511,7 +511,7 @@ const MessagesImpl = ({
// SendUserFile delivers a file without replacement text, so dropping
// assistant text for file-only turns would leave the user with no context.
const dropTextToolNames = [BRIEF_TOOL_NAME].filter((n_0): n_0 is string => n_0 !== null);
const briefFiltered = briefToolNames.length > 0 && !isTranscriptMode ? isBriefOnly ? filterForBriefTool(messagesToShowNotTruncated, briefToolNames) : dropTextToolNames.length > 0 ? dropTextInBriefTurns(messagesToShowNotTruncated, dropTextToolNames) : messagesToShowNotTruncated : messagesToShowNotTruncated;
const briefFiltered: MessageType[] = (briefToolNames.length > 0 && !isTranscriptMode ? isBriefOnly ? filterForBriefTool(messagesToShowNotTruncated as Parameters<typeof filterForBriefTool>[0], briefToolNames) : dropTextToolNames.length > 0 ? dropTextInBriefTurns(messagesToShowNotTruncated as Parameters<typeof dropTextInBriefTurns>[0], dropTextToolNames) : messagesToShowNotTruncated : messagesToShowNotTruncated) as MessageType[];
const messagesToShow = shouldTruncate ? briefFiltered.slice(-MAX_MESSAGES_TO_SHOW_IN_TRANSCRIPT_MODE) : briefFiltered;
const hasTruncatedMessages = shouldTruncate && briefFiltered.length > MAX_MESSAGES_TO_SHOW_IN_TRANSCRIPT_MODE;
const {
@@ -586,9 +586,9 @@ const MessagesImpl = ({
return b != null && isAdvisorBlock(b) && b.type === 'advisor_tool_result' && b.content.type === 'advisor_result';
}
if (msg_6.type !== 'user') return false;
const b_0 = msg_6.message.content[0];
const b_0 = (msg_6.message.content as Array<{ type: string; is_error?: boolean; tool_use_id?: string }>)[0];
if (b_0?.type !== 'tool_result' || b_0.is_error || !msg_6.toolUseResult) return false;
const name = lookupsRef.current.toolUseByToolUseID.get(b_0.tool_use_id)?.name;
const name = lookupsRef.current.toolUseByToolUseID.get(b_0.tool_use_id!)?.name;
const tool = name ? findToolByName(tools, name) : undefined;
return tool?.isResultTruncated?.(msg_6.toolUseResult as never) ?? false;
}, [tools]);
@@ -786,9 +786,9 @@ export function shouldRenderStatically(message: RenderableMessage, streamingTool
case 'assistant':
{
if (message.type === 'assistant') {
const block = message.message.content[0];
const block = (message.message.content as Array<{ type: string; id?: string }>)[0];
if (block?.type === 'server_tool_use') {
return lookups.resolvedToolUseIDs.has(block.id);
return lookups.resolvedToolUseIDs.has(block.id!);
}
}
const toolUseID = getToolUseID(message);
@@ -818,8 +818,8 @@ export function shouldRenderStatically(message: RenderableMessage, streamingTool
case 'grouped_tool_use':
{
const allResolved = message.messages.every(msg => {
const content = msg.message.content[0];
return content?.type === 'tool_use' && lookups.resolvedToolUseIDs.has(content.id);
const content = (msg.message.content as Array<{ type: string; id?: string }>)[0];
return content?.type === 'tool_use' && lookups.resolvedToolUseIDs.has(content.id!);
});
return allResolved;
}
@@ -831,4 +831,3 @@ export function shouldRenderStatically(message: RenderableMessage, streamingTool
}
}
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJmZWF0dXJlIiwiY2hhbGsiLCJVVUlEIiwiUmVmT2JqZWN0IiwiUmVhY3QiLCJ1c2VDYWxsYmFjayIsInVzZUVmZmVjdCIsInVzZU1lbW8iLCJ1c2VSZWYiLCJ1c2VTdGF0ZSIsImV2ZXJ5IiwiZ2V0SXNSZW1vdGVNb2RlIiwiQ29tbWFuZCIsIkJMQUNLX0NJUkNMRSIsInVzZVRlcm1pbmFsU2l6ZSIsIlNjcm9sbEJveEhhbmRsZSIsInVzZVRlcm1pbmFsTm90aWZpY2F0aW9uIiwiQm94IiwiVGV4dCIsInVzZVNob3J0Y3V0RGlzcGxheSIsIlNjcmVlbiIsIlRvb2xzIiwiZmluZFRvb2xCeU5hbWUiLCJBZ2VudERlZmluaXRpb25zUmVzdWx0IiwiTWVzc2FnZSIsIk1lc3NhZ2VUeXBlIiwiTm9ybWFsaXplZE1lc3NhZ2UiLCJQcm9ncmVzc01lc3NhZ2UiLCJQcm9ncmVzc01lc3NhZ2VUeXBlIiwiUmVuZGVyYWJsZU1lc3NhZ2UiLCJBZHZpc29yQmxvY2siLCJpc0Fkdmlzb3JCbG9jayIsImNvbGxhcHNlQmFja2dyb3VuZEJhc2hOb3RpZmljYXRpb25zIiwiY29sbGFwc2VIb29rU3VtbWFyaWVzIiwiY29sbGFwc2VSZWFkU2VhcmNoR3JvdXBzIiwiY29sbGFwc2VUZWFtbWF0ZVNodXRkb3ducyIsImdldEdsb2JhbENv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