mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14:25:51 +00:00
更新大量 tsx 原始文件; 已经迁移 login panel; 部分 (#121)
* style(B1-1): 格式化 ink/buddy/cli/context/screens/tasks/services/keybindings/state (43 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 修复了 Box.tsx 和 ScrollBox.tsx 中无效的 global.d.ts import。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-2): 格式化 commands (79 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-4): 格式化 components/PromptInput,FeedbackSurvey,tasks,agents,skills,design-system,wizard (73 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-5): 格式化 components其余 + hooks + tools (232 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-6): 格式化 main/entrypoints/utils/moreright (21 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: 更新 README,新增 Run.ps1/TODO.md,删除 V6.md - README.md: 大幅重写,更详细版本历史和配置示例 - Run.ps1: 新增 Windows 启动脚本 - TODO.md: 新增包完成清单 - V6.md: 删除(架构重构规划已不适用) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: 修复以前的问题 * fix: 修复 login 面板的问题 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,27 +1,40 @@
|
||||
import { feature } from 'bun:bundle';
|
||||
import figures from 'figures';
|
||||
import * as React from 'react';
|
||||
import { SentryErrorBoundary } from 'src/components/SentryErrorBoundary.js';
|
||||
import { Box, Text, useTheme } from '../../../ink.js';
|
||||
import { useAppState } from '../../../state/AppState.js';
|
||||
import { filterToolProgressMessages, type Tool, type Tools } from '../../../Tool.js';
|
||||
import type { NormalizedUserMessage, ProgressMessage } from '../../../types/message.js';
|
||||
import { deleteClassifierApproval, getClassifierApproval, getYoloClassifierApproval } from '../../../utils/classifierApprovals.js';
|
||||
import type { buildMessageLookups } from '../../../utils/messages.js';
|
||||
import { MessageResponse } from '../../MessageResponse.js';
|
||||
import { HookProgressMessage } from '../HookProgressMessage.js';
|
||||
import { feature } from 'bun:bundle'
|
||||
import figures from 'figures'
|
||||
import * as React from 'react'
|
||||
import { SentryErrorBoundary } from 'src/components/SentryErrorBoundary.js'
|
||||
import { Box, Text, useTheme } from '../../../ink.js'
|
||||
import { useAppState } from '../../../state/AppState.js'
|
||||
import {
|
||||
filterToolProgressMessages,
|
||||
type Tool,
|
||||
type Tools,
|
||||
} from '../../../Tool.js'
|
||||
import type {
|
||||
NormalizedUserMessage,
|
||||
ProgressMessage,
|
||||
} from '../../../types/message.js'
|
||||
import {
|
||||
deleteClassifierApproval,
|
||||
getClassifierApproval,
|
||||
getYoloClassifierApproval,
|
||||
} from '../../../utils/classifierApprovals.js'
|
||||
import type { buildMessageLookups } from '../../../utils/messages.js'
|
||||
import { MessageResponse } from '../../MessageResponse.js'
|
||||
import { HookProgressMessage } from '../HookProgressMessage.js'
|
||||
|
||||
type Props = {
|
||||
message: NormalizedUserMessage;
|
||||
lookups: ReturnType<typeof buildMessageLookups>;
|
||||
toolUseID: string;
|
||||
progressMessagesForMessage: ProgressMessage[];
|
||||
style?: 'condensed';
|
||||
tool?: Tool;
|
||||
tools: Tools;
|
||||
verbose: boolean;
|
||||
width: number | string;
|
||||
isTranscriptMode?: boolean;
|
||||
};
|
||||
message: NormalizedUserMessage
|
||||
lookups: ReturnType<typeof buildMessageLookups>
|
||||
toolUseID: string
|
||||
progressMessagesForMessage: ProgressMessage[]
|
||||
style?: 'condensed'
|
||||
tool?: Tool
|
||||
tools: Tools
|
||||
verbose: boolean
|
||||
width: number | string
|
||||
isTranscriptMode?: boolean
|
||||
}
|
||||
|
||||
export function UserToolSuccessMessage({
|
||||
message,
|
||||
lookups,
|
||||
@@ -32,72 +45,105 @@ export function UserToolSuccessMessage({
|
||||
tools,
|
||||
verbose,
|
||||
width,
|
||||
isTranscriptMode
|
||||
isTranscriptMode,
|
||||
}: Props): React.ReactNode {
|
||||
const [theme] = useTheme();
|
||||
const [theme] = useTheme()
|
||||
// Hook stays inside feature() ternary so external builds don't pay a
|
||||
// per-scrollback-message store subscription — same pattern as
|
||||
// UserPromptMessage.tsx.
|
||||
const isBriefOnly = feature('KAIROS') || feature('KAIROS_BRIEF') ?
|
||||
// biome-ignore lint/correctness/useHookAtTopLevel: feature() is a compile-time constant
|
||||
useAppState(s => s.isBriefOnly) : false;
|
||||
const isBriefOnly =
|
||||
feature('KAIROS') || feature('KAIROS_BRIEF')
|
||||
? // biome-ignore lint/correctness/useHookAtTopLevel: feature() is a compile-time constant
|
||||
useAppState(s => s.isBriefOnly)
|
||||
: false
|
||||
|
||||
// Capture classifier approval once on mount, then delete from Map to prevent linear growth.
|
||||
// useState lazy initializer ensures the value persists across re-renders.
|
||||
const [classifierRule] = React.useState(() => getClassifierApproval(toolUseID));
|
||||
const [yoloReason] = React.useState(() => getYoloClassifierApproval(toolUseID));
|
||||
const [classifierRule] = React.useState(() =>
|
||||
getClassifierApproval(toolUseID),
|
||||
)
|
||||
const [yoloReason] = React.useState(() =>
|
||||
getYoloClassifierApproval(toolUseID),
|
||||
)
|
||||
React.useEffect(() => {
|
||||
deleteClassifierApproval(toolUseID);
|
||||
}, [toolUseID]);
|
||||
deleteClassifierApproval(toolUseID)
|
||||
}, [toolUseID])
|
||||
|
||||
if (!message.toolUseResult || !tool) {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
|
||||
// Resumed transcripts deserialize toolUseResult via raw JSON.parse with no
|
||||
// validation (parseJSONL). A partial/corrupt/old-format result crashes
|
||||
// renderToolResultMessage on first field access (anthropics/claude-code#39817).
|
||||
// Validate against outputSchema before rendering — mirrors CollapsedReadSearchContent.
|
||||
const parsedOutput = tool.outputSchema?.safeParse(message.toolUseResult);
|
||||
const parsedOutput = tool.outputSchema?.safeParse(message.toolUseResult)
|
||||
if (parsedOutput && !parsedOutput.success) {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
const toolResult = parsedOutput?.data ?? message.toolUseResult;
|
||||
const renderedMessage = tool.renderToolResultMessage?.(toolResult as never, filterToolProgressMessages(progressMessagesForMessage), {
|
||||
style,
|
||||
theme,
|
||||
tools,
|
||||
verbose,
|
||||
isTranscriptMode,
|
||||
isBriefOnly,
|
||||
input: lookups.toolUseByToolUseID.get(toolUseID)?.input
|
||||
}) ?? null;
|
||||
const toolResult = parsedOutput?.data ?? message.toolUseResult
|
||||
|
||||
const renderedMessage =
|
||||
tool.renderToolResultMessage?.(
|
||||
toolResult as never,
|
||||
filterToolProgressMessages(progressMessagesForMessage),
|
||||
{
|
||||
style,
|
||||
theme,
|
||||
tools,
|
||||
verbose,
|
||||
isTranscriptMode,
|
||||
isBriefOnly,
|
||||
input: lookups.toolUseByToolUseID.get(toolUseID)?.input,
|
||||
},
|
||||
) ?? null
|
||||
|
||||
// Don't render anything if the tool result message is null
|
||||
if (renderedMessage === null) {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
|
||||
// Tools that return '' from userFacingName opt out of tool chrome and
|
||||
// render like plain assistant text. Skip the tool-result width constraint
|
||||
// so MarkdownTable's SAFETY_MARGIN=4 (tuned for the assistant-text 2-col
|
||||
// dot gutter) holds — otherwise tables wrap their box-drawing chars.
|
||||
const rendersAsAssistantText = tool.userFacingName(undefined) === '';
|
||||
return <Box flexDirection="column">
|
||||
<Box flexDirection="column" width={rendersAsAssistantText ? undefined : width}>
|
||||
const rendersAsAssistantText = tool.userFacingName(undefined) === ''
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Box
|
||||
flexDirection="column"
|
||||
width={rendersAsAssistantText ? undefined : width}
|
||||
>
|
||||
{renderedMessage}
|
||||
{feature('BASH_CLASSIFIER') ? classifierRule && <MessageResponse height={1}>
|
||||
{feature('BASH_CLASSIFIER')
|
||||
? classifierRule && (
|
||||
<MessageResponse height={1}>
|
||||
<Text dimColor>
|
||||
<Text color="success">{figures.tick}</Text>
|
||||
{' Auto-approved \u00b7 matched '}
|
||||
{`"${classifierRule}"`}
|
||||
</Text>
|
||||
</MessageResponse> : null}
|
||||
{feature('TRANSCRIPT_CLASSIFIER') ? yoloReason && <MessageResponse height={1}>
|
||||
</MessageResponse>
|
||||
)
|
||||
: null}
|
||||
{feature('TRANSCRIPT_CLASSIFIER')
|
||||
? yoloReason && (
|
||||
<MessageResponse height={1}>
|
||||
<Text dimColor>Allowed by auto mode classifier</Text>
|
||||
</MessageResponse> : null}
|
||||
</MessageResponse>
|
||||
)
|
||||
: null}
|
||||
</Box>
|
||||
<SentryErrorBoundary>
|
||||
<HookProgressMessage hookEvent="PostToolUse" lookups={lookups} toolUseID={toolUseID} verbose={verbose} isTranscriptMode={isTranscriptMode} />
|
||||
<HookProgressMessage
|
||||
hookEvent="PostToolUse"
|
||||
lookups={lookups}
|
||||
toolUseID={toolUseID}
|
||||
verbose={verbose}
|
||||
isTranscriptMode={isTranscriptMode}
|
||||
/>
|
||||
</SentryErrorBoundary>
|
||||
</Box>;
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user