fix(team): prevent hooks ordering crash in ToolInputPreview
Move useMemo/variable declarations BEFORE the AskUserQuestion early return to ensure hooks are called in consistent order regardless of which tool type is being displayed.
This commit is contained in:
parent
6b09b59d88
commit
daef2db07c
1 changed files with 6 additions and 6 deletions
|
|
@ -380,6 +380,12 @@ const ToolInputPreview = ({
|
||||||
toolInput: Record<string, unknown>;
|
toolInput: Record<string, unknown>;
|
||||||
projectPath?: string;
|
projectPath?: string;
|
||||||
}): React.JSX.Element => {
|
}): React.JSX.Element => {
|
||||||
|
const text = renderToolInput(toolName, toolInput, projectPath);
|
||||||
|
const fileName = getToolInputFileName(toolName, toolInput);
|
||||||
|
const lines = useMemo(() => highlightLines(text, fileName), [text, fileName]);
|
||||||
|
const rawFilePath = typeof toolInput.file_path === 'string' ? toolInput.file_path : null;
|
||||||
|
const isFileTool = FILE_TOOLS.has(toolName) && rawFilePath;
|
||||||
|
|
||||||
// AskUserQuestion: render questions with options as readable UI
|
// AskUserQuestion: render questions with options as readable UI
|
||||||
if (toolName === 'AskUserQuestion' && Array.isArray(toolInput.questions)) {
|
if (toolName === 'AskUserQuestion' && Array.isArray(toolInput.questions)) {
|
||||||
const questions = toolInput.questions as {
|
const questions = toolInput.questions as {
|
||||||
|
|
@ -452,12 +458,6 @@ const ToolInputPreview = ({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = renderToolInput(toolName, toolInput, projectPath);
|
|
||||||
const fileName = getToolInputFileName(toolName, toolInput);
|
|
||||||
const lines = useMemo(() => highlightLines(text, fileName), [text, fileName]);
|
|
||||||
const rawFilePath = typeof toolInput.file_path === 'string' ? toolInput.file_path : null;
|
|
||||||
const isFileTool = FILE_TOOLS.has(toolName) && rawFilePath;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="px-4 py-2.5">
|
<div className="px-4 py-2.5">
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue