更新大量 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:
claude-code-best
2026-04-04 23:24:27 +08:00
committed by GitHub
parent 02694918b5
commit 5b1a52b8e0
559 changed files with 103807 additions and 101817 deletions

View File

@@ -1,30 +1,27 @@
import { c as _c } from "react/compiler-runtime";
import * as React from 'react';
import { Markdown } from 'src/components/Markdown.js';
import { MessageResponse } from 'src/components/MessageResponse.js';
import { Box, Text } from '../../../ink.js';
import * as React from 'react'
import { Markdown } from 'src/components/Markdown.js'
import { MessageResponse } from 'src/components/MessageResponse.js'
import { Box, Text } from '../../../ink.js'
type Props = {
plan: string;
};
export function RejectedPlanMessage(t0) {
const $ = _c(3);
const {
plan
} = t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <Text color="subtle">User rejected Claude's plan:</Text>;
$[0] = t1;
} else {
t1 = $[0];
}
let t2;
if ($[1] !== plan) {
t2 = <MessageResponse><Box flexDirection="column">{t1}<Box borderStyle="round" borderColor="planMode" paddingX={1} overflow="hidden"><Markdown>{plan}</Markdown></Box></Box></MessageResponse>;
$[1] = plan;
$[2] = t2;
} else {
t2 = $[2];
}
return t2;
plan: string
}
export function RejectedPlanMessage({ plan }: Props): React.ReactNode {
return (
<MessageResponse>
<Box flexDirection="column">
<Text color="subtle">User rejected Claude&apos;s plan:</Text>
<Box
borderStyle="round"
borderColor="planMode"
paddingX={1}
// Necessary for Windows Terminal to render properly
overflow="hidden"
>
<Markdown>{plan}</Markdown>
</Box>
</Box>
</MessageResponse>
)
}

View File

@@ -1,15 +1,11 @@
import { c as _c } from "react/compiler-runtime";
import * as React from 'react';
import { Text } from '../../../ink.js';
import { MessageResponse } from '../../MessageResponse.js';
export function RejectedToolUseMessage() {
const $ = _c(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <MessageResponse height={1}><Text dimColor={true}>Tool use rejected</Text></MessageResponse>;
$[0] = t0;
} else {
t0 = $[0];
}
return t0;
import * as React from 'react'
import { Text } from '../../../ink.js'
import { MessageResponse } from '../../MessageResponse.js'
export function RejectedToolUseMessage(): React.ReactNode {
return (
<MessageResponse height={1}>
<Text dimColor>Tool use rejected</Text>
</MessageResponse>
)
}

View File

@@ -1,15 +1,11 @@
import { c as _c } from "react/compiler-runtime";
import * as React from 'react';
import { InterruptedByUser } from 'src/components/InterruptedByUser.js';
import { MessageResponse } from 'src/components/MessageResponse.js';
export function UserToolCanceledMessage() {
const $ = _c(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <MessageResponse height={1}><InterruptedByUser /></MessageResponse>;
$[0] = t0;
} else {
t0 = $[0];
}
return t0;
import * as React from 'react'
import { InterruptedByUser } from 'src/components/InterruptedByUser.js'
import { MessageResponse } from 'src/components/MessageResponse.js'
export function UserToolCanceledMessage(): React.ReactNode {
return (
<MessageResponse height={1}>
<InterruptedByUser />
</MessageResponse>
)
}

View File

@@ -1,102 +1,95 @@
import { c as _c } from "react/compiler-runtime";
import { feature } from 'bun:bundle';
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs';
import * as React from 'react';
import { BULLET_OPERATOR } from '../../../constants/figures.js';
import { Text } from '../../../ink.js';
import { filterToolProgressMessages, type Tool, type Tools } from '../../../Tool.js';
import type { ProgressMessage } from '../../../types/message.js';
import { INTERRUPT_MESSAGE_FOR_TOOL_USE, isClassifierDenial, PLAN_REJECTION_PREFIX, REJECT_MESSAGE_WITH_REASON_PREFIX } from '../../../utils/messages.js';
import { FallbackToolUseErrorMessage } from '../../FallbackToolUseErrorMessage.js';
import { InterruptedByUser } from '../../InterruptedByUser.js';
import { MessageResponse } from '../../MessageResponse.js';
import { RejectedPlanMessage } from './RejectedPlanMessage.js';
import { RejectedToolUseMessage } from './RejectedToolUseMessage.js';
import { feature } from 'bun:bundle'
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
import * as React from 'react'
import { BULLET_OPERATOR } from '../../../constants/figures.js'
import { Text } from '../../../ink.js'
import {
filterToolProgressMessages,
type Tool,
type Tools,
} from '../../../Tool.js'
import type { ProgressMessage } from '../../../types/message.js'
import {
INTERRUPT_MESSAGE_FOR_TOOL_USE,
isClassifierDenial,
PLAN_REJECTION_PREFIX,
REJECT_MESSAGE_WITH_REASON_PREFIX,
} from '../../../utils/messages.js'
import { FallbackToolUseErrorMessage } from '../../FallbackToolUseErrorMessage.js'
import { InterruptedByUser } from '../../InterruptedByUser.js'
import { MessageResponse } from '../../MessageResponse.js'
import { RejectedPlanMessage } from './RejectedPlanMessage.js'
import { RejectedToolUseMessage } from './RejectedToolUseMessage.js'
type Props = {
progressMessagesForMessage: ProgressMessage[];
tool?: Tool; // undefined when resuming an old conversation that uses an old tool
tools: Tools;
param: ToolResultBlockParam;
verbose: boolean;
isTranscriptMode?: boolean;
};
export function UserToolErrorMessage(t0) {
const $ = _c(14);
const {
progressMessagesForMessage,
tool,
tools,
param,
verbose,
isTranscriptMode
} = t0;
if (typeof param.content === "string" && param.content.includes(INTERRUPT_MESSAGE_FOR_TOOL_USE)) {
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <MessageResponse height={1}><InterruptedByUser /></MessageResponse>;
$[0] = t1;
} else {
t1 = $[0];
}
return t1;
progressMessagesForMessage: ProgressMessage[]
tool?: Tool // undefined when resuming an old conversation that uses an old tool
tools: Tools
param: ToolResultBlockParam
verbose: boolean
isTranscriptMode?: boolean
}
export function UserToolErrorMessage({
progressMessagesForMessage,
tool,
tools,
param,
verbose,
isTranscriptMode,
}: Props): React.ReactNode {
if (
typeof param.content === 'string' &&
param.content.includes(INTERRUPT_MESSAGE_FOR_TOOL_USE)
) {
return (
<MessageResponse height={1}>
<InterruptedByUser />
</MessageResponse>
)
}
if (typeof param.content === "string" && param.content.startsWith(PLAN_REJECTION_PREFIX)) {
let t1;
if ($[1] !== param.content) {
t1 = param.content.substring(PLAN_REJECTION_PREFIX.length);
$[1] = param.content;
$[2] = t1;
} else {
t1 = $[2];
}
const planContent = t1;
let t2;
if ($[3] !== planContent) {
t2 = <RejectedPlanMessage plan={planContent} />;
$[3] = planContent;
$[4] = t2;
} else {
t2 = $[4];
}
return t2;
if (
typeof param.content === 'string' &&
param.content.startsWith(PLAN_REJECTION_PREFIX)
) {
// Extract the plan content from the error message
const planContent = param.content.substring(PLAN_REJECTION_PREFIX.length)
return <RejectedPlanMessage plan={planContent} />
}
if (typeof param.content === "string" && param.content.startsWith(REJECT_MESSAGE_WITH_REASON_PREFIX)) {
let t1;
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <RejectedToolUseMessage />;
$[5] = t1;
} else {
t1 = $[5];
}
return t1;
if (
typeof param.content === 'string' &&
param.content.startsWith(REJECT_MESSAGE_WITH_REASON_PREFIX)
) {
return <RejectedToolUseMessage />
}
if (feature("TRANSCRIPT_CLASSIFIER") && typeof param.content === "string" && isClassifierDenial(param.content)) {
let t1;
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <MessageResponse height={1}><Text dimColor={true}>Denied by auto mode classifier {BULLET_OPERATOR} /feedback if incorrect</Text></MessageResponse>;
$[6] = t1;
} else {
t1 = $[6];
}
return t1;
if (
feature('TRANSCRIPT_CLASSIFIER') &&
typeof param.content === 'string' &&
isClassifierDenial(param.content)
) {
return (
<MessageResponse height={1}>
<Text dimColor>
Denied by auto mode classifier {BULLET_OPERATOR} /feedback if
incorrect
</Text>
</MessageResponse>
)
}
let t1;
if ($[7] !== isTranscriptMode || $[8] !== param.content || $[9] !== progressMessagesForMessage || $[10] !== tool || $[11] !== tools || $[12] !== verbose) {
t1 = tool?.renderToolUseErrorMessage?.(param.content, {
progressMessagesForMessage: filterToolProgressMessages(progressMessagesForMessage),
return (
tool?.renderToolUseErrorMessage?.(param.content, {
progressMessagesForMessage: filterToolProgressMessages(
progressMessagesForMessage,
),
tools,
verbose,
isTranscriptMode
}) ?? <FallbackToolUseErrorMessage result={param.content} verbose={verbose} />;
$[7] = isTranscriptMode;
$[8] = param.content;
$[9] = progressMessagesForMessage;
$[10] = tool;
$[11] = tools;
$[12] = verbose;
$[13] = t1;
} else {
t1 = $[13];
}
return t1;
isTranscriptMode,
}) ?? (
<FallbackToolUseErrorMessage result={param.content} verbose={verbose} />
)
)
}

View File

@@ -1,94 +1,59 @@
import { c as _c } from "react/compiler-runtime";
import * as React from 'react';
import { useTerminalSize } from '../../../hooks/useTerminalSize.js';
import { useTheme } from '../../../ink.js';
import { filterToolProgressMessages, type Tool, type Tools } from '../../../Tool.js';
import type { ProgressMessage } from '../../../types/message.js';
import type { buildMessageLookups } from '../../../utils/messages.js';
import { FallbackToolUseRejectedMessage } from '../../FallbackToolUseRejectedMessage.js';
import * as React from 'react'
import { useTerminalSize } from '../../../hooks/useTerminalSize.js'
import { useTheme } from '../../../ink.js'
import {
filterToolProgressMessages,
type Tool,
type Tools,
} from '../../../Tool.js'
import type { ProgressMessage } from '../../../types/message.js'
import type { buildMessageLookups } from '../../../utils/messages.js'
import { FallbackToolUseRejectedMessage } from '../../FallbackToolUseRejectedMessage.js'
type Props = {
input: {
[key: string]: unknown;
};
progressMessagesForMessage: ProgressMessage[];
style?: 'condensed';
tool?: Tool;
tools: Tools;
lookups: ReturnType<typeof buildMessageLookups>;
verbose: boolean;
isTranscriptMode?: boolean;
};
export function UserToolRejectMessage(t0) {
const $ = _c(13);
const {
input,
progressMessagesForMessage,
style,
tool,
tools,
verbose,
isTranscriptMode
} = t0;
const {
columns
} = useTerminalSize();
const [theme] = useTheme();
if (!tool || !tool.renderToolUseRejectedMessage) {
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <FallbackToolUseRejectedMessage />;
$[0] = t1;
} else {
t1 = $[0];
}
return t1;
}
const t1 = tool.inputSchema;
let t2;
let t3;
if ($[1] !== columns || $[2] !== input || $[3] !== isTranscriptMode || $[4] !== progressMessagesForMessage || $[5] !== style || $[6] !== theme || $[7] !== tool || $[8] !== tools || $[9] !== verbose) {
t3 = Symbol.for("react.early_return_sentinel");
bb0: {
const parsedInput = t1.safeParse(input);
if (!parsedInput.success) {
let t4;
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
t4 = <FallbackToolUseRejectedMessage />;
$[12] = t4;
} else {
t4 = $[12];
}
t3 = t4;
break bb0;
}
t2 = tool.renderToolUseRejectedMessage(parsedInput.data, {
columns,
messages: [],
tools,
verbose,
progressMessagesForMessage: filterToolProgressMessages(progressMessagesForMessage),
style,
theme,
isTranscriptMode
}) ?? <FallbackToolUseRejectedMessage />;
}
$[1] = columns;
$[2] = input;
$[3] = isTranscriptMode;
$[4] = progressMessagesForMessage;
$[5] = style;
$[6] = theme;
$[7] = tool;
$[8] = tools;
$[9] = verbose;
$[10] = t2;
$[11] = t3;
} else {
t2 = $[10];
t3 = $[11];
}
if (t3 !== Symbol.for("react.early_return_sentinel")) {
return t3;
}
return t2;
input: { [key: string]: unknown }
progressMessagesForMessage: ProgressMessage[]
style?: 'condensed'
tool?: Tool
tools: Tools
lookups: ReturnType<typeof buildMessageLookups>
verbose: boolean
isTranscriptMode?: boolean
}
export function UserToolRejectMessage({
input,
progressMessagesForMessage,
style,
tool,
tools,
verbose,
isTranscriptMode,
}: Props): React.ReactNode {
const { columns } = useTerminalSize()
const [theme] = useTheme()
if (!tool || !tool.renderToolUseRejectedMessage) {
return <FallbackToolUseRejectedMessage />
}
const parsedInput = tool.inputSchema.safeParse(input)
if (!parsedInput.success) {
return <FallbackToolUseRejectedMessage />
}
return (
tool.renderToolUseRejectedMessage(parsedInput.data, {
columns,
messages: [],
tools,
verbose,
progressMessagesForMessage: filterToolProgressMessages(
progressMessagesForMessage,
),
style,
theme,
isTranscriptMode,
}) ?? <FallbackToolUseRejectedMessage />
)
}

View File

@@ -1,105 +1,101 @@
import { c as _c } from "react/compiler-runtime";
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs';
import * as React from 'react';
import type { Tools } from '../../../Tool.js';
import type { NormalizedUserMessage, ProgressMessage } from '../../../types/message.js';
import { type buildMessageLookups, CANCEL_MESSAGE, INTERRUPT_MESSAGE_FOR_TOOL_USE, REJECT_MESSAGE } from '../../../utils/messages.js';
import { UserToolCanceledMessage } from './UserToolCanceledMessage.js';
import { UserToolErrorMessage } from './UserToolErrorMessage.js';
import { UserToolRejectMessage } from './UserToolRejectMessage.js';
import { UserToolSuccessMessage } from './UserToolSuccessMessage.js';
import { useGetToolFromMessages } from './utils.js';
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
import * as React from 'react'
import type { Tools } from '../../../Tool.js'
import type {
NormalizedUserMessage,
ProgressMessage,
} from '../../../types/message.js'
import {
type buildMessageLookups,
CANCEL_MESSAGE,
INTERRUPT_MESSAGE_FOR_TOOL_USE,
REJECT_MESSAGE,
} from '../../../utils/messages.js'
import { UserToolCanceledMessage } from './UserToolCanceledMessage.js'
import { UserToolErrorMessage } from './UserToolErrorMessage.js'
import { UserToolRejectMessage } from './UserToolRejectMessage.js'
import { UserToolSuccessMessage } from './UserToolSuccessMessage.js'
import { useGetToolFromMessages } from './utils.js'
type Props = {
param: ToolResultBlockParam;
message: NormalizedUserMessage;
lookups: ReturnType<typeof buildMessageLookups>;
progressMessagesForMessage: ProgressMessage[];
style?: 'condensed';
tools: Tools;
verbose: boolean;
width: number | string;
isTranscriptMode?: boolean;
};
export function UserToolResultMessage(t0) {
const $ = _c(28);
const {
param,
message,
lookups,
progressMessagesForMessage,
style,
tools,
verbose,
width,
isTranscriptMode
} = t0;
const toolUse = useGetToolFromMessages(param.tool_use_id, tools, lookups);
if (!toolUse) {
return null;
}
if (typeof param.content === "string" && param.content.startsWith(CANCEL_MESSAGE)) {
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <UserToolCanceledMessage />;
$[0] = t1;
} else {
t1 = $[0];
}
return t1;
}
if (typeof param.content === "string" && param.content.startsWith(REJECT_MESSAGE) || param.content === INTERRUPT_MESSAGE_FOR_TOOL_USE) {
const t1 = toolUse.toolUse.input as {
[key: string]: unknown;
};
let t2;
if ($[1] !== isTranscriptMode || $[2] !== lookups || $[3] !== progressMessagesForMessage || $[4] !== style || $[5] !== t1 || $[6] !== toolUse.tool || $[7] !== tools || $[8] !== verbose) {
t2 = <UserToolRejectMessage input={t1} progressMessagesForMessage={progressMessagesForMessage} tool={toolUse.tool} tools={tools} lookups={lookups} style={style} verbose={verbose} isTranscriptMode={isTranscriptMode} />;
$[1] = isTranscriptMode;
$[2] = lookups;
$[3] = progressMessagesForMessage;
$[4] = style;
$[5] = t1;
$[6] = toolUse.tool;
$[7] = tools;
$[8] = verbose;
$[9] = t2;
} else {
t2 = $[9];
}
return t2;
}
if (param.is_error) {
let t1;
if ($[10] !== isTranscriptMode || $[11] !== param || $[12] !== progressMessagesForMessage || $[13] !== toolUse.tool || $[14] !== tools || $[15] !== verbose) {
t1 = <UserToolErrorMessage progressMessagesForMessage={progressMessagesForMessage} tool={toolUse.tool} tools={tools} param={param} verbose={verbose} isTranscriptMode={isTranscriptMode} />;
$[10] = isTranscriptMode;
$[11] = param;
$[12] = progressMessagesForMessage;
$[13] = toolUse.tool;
$[14] = tools;
$[15] = verbose;
$[16] = t1;
} else {
t1 = $[16];
}
return t1;
}
let t1;
if ($[17] !== isTranscriptMode || $[18] !== lookups || $[19] !== message || $[20] !== progressMessagesForMessage || $[21] !== style || $[22] !== toolUse.tool || $[23] !== toolUse.toolUse.id || $[24] !== tools || $[25] !== verbose || $[26] !== width) {
t1 = <UserToolSuccessMessage message={message} lookups={lookups} toolUseID={toolUse.toolUse.id} progressMessagesForMessage={progressMessagesForMessage} style={style} tool={toolUse.tool} tools={tools} verbose={verbose} width={width} isTranscriptMode={isTranscriptMode} />;
$[17] = isTranscriptMode;
$[18] = lookups;
$[19] = message;
$[20] = progressMessagesForMessage;
$[21] = style;
$[22] = toolUse.tool;
$[23] = toolUse.toolUse.id;
$[24] = tools;
$[25] = verbose;
$[26] = width;
$[27] = t1;
} else {
t1 = $[27];
}
return t1;
param: ToolResultBlockParam
message: NormalizedUserMessage
lookups: ReturnType<typeof buildMessageLookups>
progressMessagesForMessage: ProgressMessage[]
style?: 'condensed'
tools: Tools
verbose: boolean
width: number | string
isTranscriptMode?: boolean
}
export function UserToolResultMessage({
param,
message,
lookups,
progressMessagesForMessage,
style,
tools,
verbose,
width,
isTranscriptMode,
}: Props): React.ReactNode {
const toolUse = useGetToolFromMessages(param.tool_use_id, tools, lookups)
if (!toolUse) {
return null
}
if (
typeof param.content === 'string' &&
param.content.startsWith(CANCEL_MESSAGE)
) {
return <UserToolCanceledMessage />
}
if (
(typeof param.content === 'string' &&
param.content.startsWith(REJECT_MESSAGE)) ||
param.content === INTERRUPT_MESSAGE_FOR_TOOL_USE
) {
return (
<UserToolRejectMessage
input={toolUse.toolUse.input as { [key: string]: unknown }}
progressMessagesForMessage={progressMessagesForMessage}
tool={toolUse.tool}
tools={tools}
lookups={lookups}
style={style}
verbose={verbose}
isTranscriptMode={isTranscriptMode}
/>
)
}
if (param.is_error) {
return (
<UserToolErrorMessage
progressMessagesForMessage={progressMessagesForMessage}
tool={toolUse.tool}
tools={tools}
param={param}
verbose={verbose}
isTranscriptMode={isTranscriptMode}
/>
)
}
return (
<UserToolSuccessMessage
message={message}
lookups={lookups}
toolUseID={toolUse.toolUse.id}
progressMessagesForMessage={progressMessagesForMessage}
style={style}
tool={toolUse.tool}
tools={tools}
verbose={verbose}
width={width}
isTranscriptMode={isTranscriptMode}
/>
)
}

View File

@@ -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>
)
}

View File

@@ -1,43 +1,22 @@
import { c as _c } from "react/compiler-runtime";
import type { ToolUseBlockParam } from '@anthropic-ai/sdk/resources/index.mjs';
import { useMemo } from 'react';
import { findToolByName, type Tool, type Tools } from '../../../Tool.js';
import type { buildMessageLookups } from '../../../utils/messages.js';
export function useGetToolFromMessages(toolUseID, tools, lookups) {
const $ = _c(7);
let t0;
if ($[0] !== lookups.toolUseByToolUseID || $[1] !== toolUseID || $[2] !== tools) {
bb0: {
const toolUse = lookups.toolUseByToolUseID.get(toolUseID);
if (!toolUse) {
t0 = null;
break bb0;
}
const tool = findToolByName(tools, toolUse.name);
if (!tool) {
t0 = null;
break bb0;
}
let t1;
if ($[4] !== tool || $[5] !== toolUse) {
t1 = {
tool,
toolUse
};
$[4] = tool;
$[5] = toolUse;
$[6] = t1;
} else {
t1 = $[6];
}
t0 = t1;
import type { ToolUseBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
import { useMemo } from 'react'
import { findToolByName, type Tool, type Tools } from '../../../Tool.js'
import type { buildMessageLookups } from '../../../utils/messages.js'
export function useGetToolFromMessages(
toolUseID: string,
tools: Tools,
lookups: ReturnType<typeof buildMessageLookups>,
): { tool: Tool; toolUse: ToolUseBlockParam } | null {
return useMemo(() => {
const toolUse = lookups.toolUseByToolUseID.get(toolUseID)
if (!toolUse) {
return null
}
$[0] = lookups.toolUseByToolUseID;
$[1] = toolUseID;
$[2] = tools;
$[3] = t0;
} else {
t0 = $[3];
}
return t0;
const tool = findToolByName(tools, toolUse.name)
if (!tool) {
return null
}
return { tool, toolUse }
}, [toolUseID, lookups, tools])
}