Skip to content

Commit e1f51d7

Browse files
committed
fix: prevent infinite recursion in Trans components in ChatRow
Fixes #6937 - Maximum call stack size exceeded error The issue was caused by passing JSX elements with children to the Trans component's components prop. When the translation string also contained the same tags, it created infinite recursion during interpolation. Changed all Trans components to use self-closing tags (e.g., <code />) instead of tags with children (e.g., <code>{value}</code>) to prevent the recursion issue.
1 parent 76e5a72 commit e1f51d7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -479,13 +479,13 @@ export const ChatRowContent = ({
479479
{tool.path ? (
480480
<Trans
481481
i18nKey="chat:codebaseSearch.wantsToSearchWithPath"
482-
components={{ code: <code></code> }}
482+
components={{ code: <code /> }}
483483
values={{ query: tool.query, path: tool.path }}
484484
/>
485485
) : (
486486
<Trans
487487
i18nKey="chat:codebaseSearch.wantsToSearch"
488-
components={{ code: <code></code> }}
488+
components={{ code: <code /> }}
489489
values={{ query: tool.query }}
490490
/>
491491
)}
@@ -696,7 +696,7 @@ export const ChatRowContent = ({
696696
? "chat:directoryOperations.wantsToSearchOutsideWorkspace"
697697
: "chat:directoryOperations.wantsToSearch"
698698
}
699-
components={{ code: <code>{tool.regex}</code> }}
699+
components={{ code: <code /> }}
700700
values={{ regex: tool.regex }}
701701
/>
702702
) : (
@@ -706,7 +706,7 @@ export const ChatRowContent = ({
706706
? "chat:directoryOperations.didSearchOutsideWorkspace"
707707
: "chat:directoryOperations.didSearch"
708708
}
709-
components={{ code: <code>{tool.regex}</code> }}
709+
components={{ code: <code /> }}
710710
values={{ regex: tool.regex }}
711711
/>
712712
)}
@@ -732,13 +732,13 @@ export const ChatRowContent = ({
732732
{tool.reason ? (
733733
<Trans
734734
i18nKey="chat:modes.wantsToSwitchWithReason"
735-
components={{ code: <code>{tool.mode}</code> }}
735+
components={{ code: <code /> }}
736736
values={{ mode: tool.mode, reason: tool.reason }}
737737
/>
738738
) : (
739739
<Trans
740740
i18nKey="chat:modes.wantsToSwitch"
741-
components={{ code: <code>{tool.mode}</code> }}
741+
components={{ code: <code /> }}
742742
values={{ mode: tool.mode }}
743743
/>
744744
)}
@@ -748,13 +748,13 @@ export const ChatRowContent = ({
748748
{tool.reason ? (
749749
<Trans
750750
i18nKey="chat:modes.didSwitchWithReason"
751-
components={{ code: <code>{tool.mode}</code> }}
751+
components={{ code: <code /> }}
752752
values={{ mode: tool.mode, reason: tool.reason }}
753753
/>
754754
) : (
755755
<Trans
756756
i18nKey="chat:modes.didSwitch"
757-
components={{ code: <code>{tool.mode}</code> }}
757+
components={{ code: <code /> }}
758758
values={{ mode: tool.mode }}
759759
/>
760760
)}
@@ -772,7 +772,7 @@ export const ChatRowContent = ({
772772
<span style={{ fontWeight: "bold" }}>
773773
<Trans
774774
i18nKey="chat:subtasks.wantsToCreate"
775-
components={{ code: <code>{tool.mode}</code> }}
775+
components={{ code: <code /> }}
776776
values={{ mode: tool.mode }}
777777
/>
778778
</span>

0 commit comments

Comments
 (0)