mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 22:35:51 +00:00
feat: 全部类型问题解决
This commit is contained in:
@@ -64,7 +64,7 @@ export function BridgeDialog({ onDone }: Props): React.ReactNode {
|
||||
return
|
||||
}
|
||||
qrToString(displayUrl, {
|
||||
type: 'utf8',
|
||||
type: 'terminal',
|
||||
errorCorrectionLevel: 'L',
|
||||
small: true,
|
||||
})
|
||||
|
||||
@@ -613,7 +613,7 @@ async function generateTitle(
|
||||
},
|
||||
})
|
||||
|
||||
const _firstBlock = response.message.content[0] as unknown as Record<string, unknown> | undefined
|
||||
const _firstBlock = response?.message?.content?.[0] as unknown as Record<string, unknown> | undefined
|
||||
const title =
|
||||
_firstBlock?.type === 'text'
|
||||
? (_firstBlock.text as string)
|
||||
|
||||
@@ -35,7 +35,7 @@ function hasMemoryFileRead(messages: Message[]): boolean {
|
||||
if (message.type !== 'assistant') {
|
||||
continue
|
||||
}
|
||||
const content = message.message.content
|
||||
const content = message.message!.content
|
||||
if (!Array.isArray(content)) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -242,8 +242,8 @@ export function countUnseenAssistantTurns(
|
||||
|
||||
function assistantHasVisibleText(m: Message): boolean {
|
||||
if (m.type !== 'assistant') return false
|
||||
if (!Array.isArray(m.message.content)) return false
|
||||
for (const b of m.message.content) {
|
||||
if (!Array.isArray(m.message!.content)) return false
|
||||
for (const b of m.message!.content) {
|
||||
if (typeof b !== 'string' && b.type === 'text' && b.text.trim() !== '') return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -748,9 +748,9 @@ function UserMessageOption({
|
||||
)
|
||||
}
|
||||
|
||||
const content = userMessage.message.content
|
||||
const content = userMessage.message!.content
|
||||
const lastBlock =
|
||||
typeof content === 'string' ? null : content[content.length - 1]
|
||||
typeof content === 'string' ? null : content![content!.length - 1]
|
||||
const rawMessageText =
|
||||
typeof content === 'string'
|
||||
? content.trim()
|
||||
@@ -897,8 +897,8 @@ export function selectableUserMessagesFilter(
|
||||
return false
|
||||
}
|
||||
if (
|
||||
Array.isArray(message.message.content) &&
|
||||
message.message.content[0]?.type === 'tool_result'
|
||||
Array.isArray(message.message!.content) &&
|
||||
message.message!.content[0]?.type === 'tool_result'
|
||||
) {
|
||||
return false
|
||||
}
|
||||
@@ -912,9 +912,9 @@ export function selectableUserMessagesFilter(
|
||||
return false
|
||||
}
|
||||
|
||||
const content = message.message.content
|
||||
const content = message.message!.content
|
||||
const lastBlock =
|
||||
typeof content === 'string' ? null : content[content.length - 1]
|
||||
typeof content === 'string' ? null : content![content!.length - 1]
|
||||
const messageText =
|
||||
typeof content === 'string'
|
||||
? content.trim()
|
||||
@@ -960,7 +960,7 @@ export function messagesAfterAreOnlySynthetic(
|
||||
|
||||
// Assistant with actual content = meaningful
|
||||
if (msg.type === 'assistant') {
|
||||
const content = msg.message.content
|
||||
const content = msg.message!.content
|
||||
if (Array.isArray(content)) {
|
||||
const hasMeaningfulContent = content.some(
|
||||
block =>
|
||||
|
||||
@@ -15,7 +15,7 @@ export function MessageTimestamp({
|
||||
isTranscriptMode &&
|
||||
message.timestamp &&
|
||||
message.type === 'assistant' &&
|
||||
(Array.isArray(message.message.content) ? (message.message.content as {type: string}[]).some(c => c.type === 'text') : false)
|
||||
(Array.isArray(message.message!.content) ? (message.message!.content as {type: string}[]).some(c => c.type === 'text') : false)
|
||||
|
||||
if (!shouldShowTimestamp) {
|
||||
return null
|
||||
|
||||
@@ -460,7 +460,7 @@ const MessagesImpl = ({
|
||||
for (let i = normalizedMessages.length - 1; i >= 0; i--) {
|
||||
const msg = normalizedMessages[i]
|
||||
if (msg?.type === 'assistant') {
|
||||
const content = msg.message.content as Array<{ type: string }>
|
||||
const content = msg.message!.content as Array<{ type: string }>
|
||||
// Find the last thinking block in this message
|
||||
for (let j = content.length - 1; j >= 0; j--) {
|
||||
if (content[j]?.type === 'thinking') {
|
||||
@@ -468,7 +468,7 @@ const MessagesImpl = ({
|
||||
}
|
||||
}
|
||||
} else if (msg?.type === 'user') {
|
||||
const content = msg.message.content as Array<{ type: string }>
|
||||
const content = msg.message!.content as Array<{ type: string }>
|
||||
const hasToolResult = content.some(
|
||||
block => block.type === 'tool_result',
|
||||
)
|
||||
@@ -488,7 +488,7 @@ const MessagesImpl = ({
|
||||
for (let i = normalizedMessages.length - 1; i >= 0; i--) {
|
||||
const msg = normalizedMessages[i]
|
||||
if (msg?.type === 'user') {
|
||||
const content = msg.message.content as Array<{ type: string; text?: string }>
|
||||
const content = msg.message!.content as Array<{ type: string; text?: string }>
|
||||
// Check if any text content is bash output
|
||||
for (const block of content) {
|
||||
if (block.type === 'text') {
|
||||
@@ -741,7 +741,8 @@ const MessagesImpl = ({
|
||||
(msg: RenderableMessage): boolean => {
|
||||
if (msg.type === 'collapsed_read_search') return true
|
||||
if (msg.type === 'assistant') {
|
||||
const b = msg.message.content[0] as unknown as AdvisorBlock | undefined
|
||||
const content = msg.message!.content
|
||||
const b = (Array.isArray(content) ? content[0] : undefined) as unknown as AdvisorBlock | undefined
|
||||
return (
|
||||
b != null &&
|
||||
isAdvisorBlock(b) &&
|
||||
@@ -750,11 +751,11 @@ const MessagesImpl = ({
|
||||
)
|
||||
}
|
||||
if (msg.type !== 'user') return false
|
||||
const b = (msg.message.content as Array<{ type: string; tool_use_id?: string; is_error?: boolean; [key: string]: unknown }>)[0]
|
||||
const b = (msg.message!.content as Array<{ type: string; tool_use_id?: string; is_error?: boolean; [key: string]: unknown }>)[0]
|
||||
if (b?.type !== 'tool_result' || b.is_error || !msg.toolUseResult)
|
||||
return false
|
||||
const name = lookupsRef.current.toolUseByToolUseID.get(
|
||||
b.tool_use_id,
|
||||
b.tool_use_id ?? '',
|
||||
)?.name
|
||||
const tool = name ? findToolByName(tools, name) : undefined
|
||||
return tool?.isResultTruncated?.(msg.toolUseResult as never) ?? false
|
||||
@@ -1111,7 +1112,7 @@ export function shouldRenderStatically(
|
||||
case 'user':
|
||||
case 'assistant': {
|
||||
if (message.type === 'assistant') {
|
||||
const block = (message.message.content as Array<{ type: string; id?: string }>)[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!)
|
||||
}
|
||||
@@ -1142,7 +1143,7 @@ export function shouldRenderStatically(
|
||||
}
|
||||
case 'grouped_tool_use': {
|
||||
const allResolved = message.messages.every(msg => {
|
||||
const content = (msg.message.content as Array<{ type: string; id?: string }>)[0]
|
||||
const content = (msg.message!.content as Array<{ type: string; id?: string }>)[0]
|
||||
return (
|
||||
content?.type === 'tool_use' &&
|
||||
lookups.resolvedToolUseIDs.has(content.id!)
|
||||
@@ -1155,5 +1156,7 @@ export function shouldRenderStatically(
|
||||
// (In transcript mode, we already returned true at the top of this function)
|
||||
return false
|
||||
}
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3140,8 +3140,8 @@ function getInitialPasteId(messages: Message[]): number {
|
||||
}
|
||||
}
|
||||
// Check text paste references in message content
|
||||
if (Array.isArray(message.message.content)) {
|
||||
for (const block of message.message.content) {
|
||||
if (Array.isArray(message.message!.content)) {
|
||||
for (const block of message.message!.content) {
|
||||
if (block.type === 'text') {
|
||||
const refs = parseReferences(block.text)
|
||||
for (const ref of refs) {
|
||||
|
||||
@@ -87,6 +87,7 @@ export function isNavigableMessage(msg: NavigableMessage): boolean {
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type PrimaryInput = {
|
||||
@@ -395,6 +396,7 @@ export function copyTextOf(msg: NavigableMessage): string {
|
||||
return `[${a.type}]`
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function toolResultText(r: NormalizedUserMessage): string {
|
||||
|
||||
@@ -63,6 +63,6 @@ export function isNullRenderingAttachment(
|
||||
): boolean {
|
||||
return (
|
||||
msg.type === 'attachment' &&
|
||||
NULL_RENDERING_ATTACHMENT_TYPES.has(msg.attachment.type as Attachment['type'])
|
||||
NULL_RENDERING_ATTACHMENT_TYPES.has(msg.attachment!.type as Attachment['type'])
|
||||
)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export function FallbackPermissionRequest({
|
||||
event: 'accept',
|
||||
metadata: {
|
||||
language_name: 'none',
|
||||
message_id: toolUseConfirm.assistantMessage.message.id,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id!,
|
||||
platform: env.platform,
|
||||
},
|
||||
})
|
||||
@@ -66,7 +66,7 @@ export function FallbackPermissionRequest({
|
||||
event: 'accept',
|
||||
metadata: {
|
||||
language_name: 'none',
|
||||
message_id: toolUseConfirm.assistantMessage.message.id,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id!,
|
||||
platform: env.platform,
|
||||
},
|
||||
})
|
||||
@@ -92,7 +92,7 @@ export function FallbackPermissionRequest({
|
||||
event: 'reject',
|
||||
metadata: {
|
||||
language_name: 'none',
|
||||
message_id: toolUseConfirm.assistantMessage.message.id,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id!,
|
||||
platform: env.platform,
|
||||
},
|
||||
})
|
||||
@@ -111,7 +111,7 @@ export function FallbackPermissionRequest({
|
||||
event: 'reject',
|
||||
metadata: {
|
||||
language_name: 'none',
|
||||
message_id: toolUseConfirm.assistantMessage.message.id,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id!,
|
||||
platform: env.platform,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -89,7 +89,7 @@ export function useFilePermissionDialog<T extends ToolInput>({
|
||||
const onChange = useCallback(
|
||||
(option: PermissionOption, input: T, feedback?: string) => {
|
||||
const params: PermissionHandlerParams = {
|
||||
messageId: toolUseConfirm.assistantMessage.message.id,
|
||||
messageId: toolUseConfirm.assistantMessage.message.id!,
|
||||
path: filePath,
|
||||
toolUseConfirm,
|
||||
toolPermissionContext,
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as React from 'react'
|
||||
import { Suspense, use, useMemo } from 'react'
|
||||
import { Box, NoSelect, Text } from '@anthropic/ink'
|
||||
import type {
|
||||
NotebookCell,
|
||||
NotebookCellType,
|
||||
NotebookContent,
|
||||
} from '../../../types/notebook.js'
|
||||
@@ -79,7 +80,7 @@ function NotebookEditToolDiffInner({
|
||||
}
|
||||
return ''
|
||||
}
|
||||
const cell = notebookData.cells.find(cell => cell.id === cell_id)
|
||||
const cell = notebookData.cells.find((cell: NotebookCell) => cell.id === cell_id)
|
||||
if (!cell) {
|
||||
return ''
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ export function SkillPermissionRequest(
|
||||
event: 'accept',
|
||||
metadata: {
|
||||
language_name: 'none',
|
||||
message_id: toolUseConfirm.assistantMessage.message.id,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id!,
|
||||
platform: env.platform,
|
||||
},
|
||||
})
|
||||
@@ -142,7 +142,7 @@ export function SkillPermissionRequest(
|
||||
event: 'accept',
|
||||
metadata: {
|
||||
language_name: 'none',
|
||||
message_id: toolUseConfirm.assistantMessage.message.id,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id!,
|
||||
platform: env.platform,
|
||||
},
|
||||
})
|
||||
@@ -169,7 +169,7 @@ export function SkillPermissionRequest(
|
||||
event: 'accept',
|
||||
metadata: {
|
||||
language_name: 'none',
|
||||
message_id: toolUseConfirm.assistantMessage.message.id,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id!,
|
||||
platform: env.platform,
|
||||
},
|
||||
})
|
||||
@@ -201,7 +201,7 @@ export function SkillPermissionRequest(
|
||||
event: 'reject',
|
||||
metadata: {
|
||||
language_name: 'none',
|
||||
message_id: toolUseConfirm.assistantMessage.message.id,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id!,
|
||||
platform: env.platform,
|
||||
},
|
||||
})
|
||||
@@ -220,7 +220,7 @@ export function SkillPermissionRequest(
|
||||
event: 'reject',
|
||||
metadata: {
|
||||
language_name: 'none',
|
||||
message_id: toolUseConfirm.assistantMessage.message.id,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id!,
|
||||
platform: env.platform,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -201,7 +201,7 @@ export function usePermissionRequestLogging(
|
||||
event: 'response',
|
||||
metadata: {
|
||||
language_name: unaryEvent.language_name,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id,
|
||||
message_id: toolUseConfirm.assistantMessage.message.id!,
|
||||
platform: env.platform,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -17,7 +17,7 @@ export function logUnaryPermissionEvent(
|
||||
event,
|
||||
metadata: {
|
||||
language_name: 'none',
|
||||
message_id,
|
||||
message_id: message_id!,
|
||||
platform: getHostPlatformForAnalytics(),
|
||||
hasFeedback: hasFeedback ?? false,
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { feature } from 'bun:bundle'
|
||||
import figures from 'figures'
|
||||
import type { AgentId } from '../../types/ids.js'
|
||||
import React, {
|
||||
type ReactNode,
|
||||
useEffect,
|
||||
@@ -535,12 +536,12 @@ export function BackgroundTasksDialog({
|
||||
}
|
||||
onSkipAgent={
|
||||
task.status === 'running' && skipWorkflowAgent
|
||||
? agentId => skipWorkflowAgent(task.id, agentId, setAppState)
|
||||
? (agentId: AgentId) => skipWorkflowAgent(task.id, agentId, setAppState)
|
||||
: undefined
|
||||
}
|
||||
onRetryAgent={
|
||||
task.status === 'running' && retryWorkflowAgent
|
||||
? agentId => retryWorkflowAgent(task.id, agentId, setAppState)
|
||||
? (agentId: AgentId) => retryWorkflowAgent(task.id, agentId, setAppState)
|
||||
: undefined
|
||||
}
|
||||
onBack={goBackToList}
|
||||
|
||||
Reference in New Issue
Block a user