mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
Eliminate unsafe `as any` casts across 21 non-test source files, replacing them with specific type annotations: - Bridge transport: use StdoutMessage type for write/writeBatch calls - print.ts: type msg.request as Record<string, unknown> for unknown SDK control subtypes; use StdoutMessage for output.enqueue() - API providers (openai/grok/gemini): import ChatCompletion types, type streams as AsyncIterable<ChatCompletionChunk>, type request bodies as ChatCompletionCreateParamsStreaming - Computer use executor: use Partial<ResolvePrepareCaptureResult> for cross-platform screenshot result - Components: replace Ink color string casts with proper typing - Win32 bridge: type stdin as Writable after null check All 2453 tests pass with 0 failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
106 lines
3.2 KiB
TypeScript
106 lines
3.2 KiB
TypeScript
import * as React from 'react'
|
|
import { BLACK_CIRCLE } from '../constants/figures.js'
|
|
import { Box, Text } from '@anthropic/ink'
|
|
import type { Screen } from '../screens/REPL.js'
|
|
import type { NormalizedUserMessage } from '../types/message.js'
|
|
import { getUserMessageText } from '../utils/messages.js'
|
|
import { ConfigurableShortcutHint } from './ConfigurableShortcutHint.js'
|
|
import { MessageResponse } from './MessageResponse.js'
|
|
|
|
type Props = {
|
|
message: NormalizedUserMessage
|
|
screen: Screen
|
|
}
|
|
|
|
export function CompactSummary({ message, screen }: Props): React.ReactNode {
|
|
const isTranscriptMode = screen === 'transcript'
|
|
const textContent = getUserMessageText(message) || ''
|
|
const metadata = message.summarizeMetadata as {
|
|
messagesSummarized?: number
|
|
direction?: string
|
|
userContext?: string
|
|
} | undefined
|
|
|
|
// "Summarize from here" with metadata
|
|
if (metadata) {
|
|
return (
|
|
<Box flexDirection="column" marginTop={1}>
|
|
<Box flexDirection="row">
|
|
<Box minWidth={2}>
|
|
<Text color="text">{BLACK_CIRCLE}</Text>
|
|
</Box>
|
|
<Box flexDirection="column">
|
|
<Text bold>Summarized conversation</Text>
|
|
{!isTranscriptMode && (
|
|
<MessageResponse>
|
|
<Box flexDirection="column">
|
|
<Text dimColor>
|
|
Summarized {metadata.messagesSummarized} messages{' '}
|
|
{metadata.direction === 'up_to'
|
|
? 'up to this point'
|
|
: 'from this point'}
|
|
</Text>
|
|
{metadata.userContext && (
|
|
<Text dimColor>
|
|
Context: {'\u201c'}
|
|
{metadata.userContext}
|
|
{'\u201d'}
|
|
</Text>
|
|
)}
|
|
<Text dimColor>
|
|
<ConfigurableShortcutHint
|
|
action="app:toggleTranscript"
|
|
context="Global"
|
|
fallback="ctrl+o"
|
|
description="expand history"
|
|
parens
|
|
/>
|
|
</Text>
|
|
</Box>
|
|
</MessageResponse>
|
|
)}
|
|
{isTranscriptMode && (
|
|
<MessageResponse>
|
|
<Text>{textContent}</Text>
|
|
</MessageResponse>
|
|
)}
|
|
</Box>
|
|
</Box>
|
|
</Box>
|
|
)
|
|
}
|
|
|
|
// Default compact summary (auto-compact)
|
|
return (
|
|
<Box flexDirection="column" marginTop={1}>
|
|
<Box flexDirection="row">
|
|
<Box minWidth={2}>
|
|
<Text color="text">{BLACK_CIRCLE}</Text>
|
|
</Box>
|
|
<Box flexDirection="column">
|
|
<Text bold>
|
|
Compact summary
|
|
{!isTranscriptMode && (
|
|
<Text dimColor>
|
|
{' '}
|
|
<ConfigurableShortcutHint
|
|
action="app:toggleTranscript"
|
|
context="Global"
|
|
fallback="ctrl+o"
|
|
description="expand"
|
|
parens
|
|
/>
|
|
</Text>
|
|
)}
|
|
</Text>
|
|
</Box>
|
|
</Box>
|
|
{isTranscriptMode && (
|
|
<MessageResponse>
|
|
<Text>{textContent}</Text>
|
|
</MessageResponse>
|
|
)}
|
|
</Box>
|
|
)
|
|
}
|