Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions webview-ui/src/components/chat/ChatRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,13 @@ export const ChatRowContent = ({
{tool.path ? (
<Trans
i18nKey="chat:codebaseSearch.wantsToSearchWithPath"
components={{ code: <code></code> }}
components={{ code: <code /> }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix! The change from <code>{value}</code> to <code /> correctly prevents the infinite recursion. However, have you checked if there are other Trans components in the codebase that might have the same pattern? A quick search for similar patterns across the codebase would ensure we've caught all instances of this issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All instances are covered

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment here explaining why self-closing tags must be used instead of tags with children. Something like:

Suggested change
components={{ code: <code /> }}
// Note: Use self-closing tags in components prop to prevent infinite recursion
// when translation strings contain the same tags (e.g., <code>)
components={{ code: <code /> }}

This would help prevent future developers from reintroducing this issue.

values={{ query: tool.query, path: tool.path }}
/>
) : (
<Trans
i18nKey="chat:codebaseSearch.wantsToSearch"
components={{ code: <code></code> }}
components={{ code: <code /> }}
values={{ query: tool.query }}
/>
)}
Expand Down Expand Up @@ -696,7 +696,7 @@ export const ChatRowContent = ({
? "chat:directoryOperations.wantsToSearchOutsideWorkspace"
: "chat:directoryOperations.wantsToSearch"
}
components={{ code: <code>{tool.regex}</code> }}
components={{ code: <code /> }}
values={{ regex: tool.regex }}
/>
) : (
Expand All @@ -706,7 +706,7 @@ export const ChatRowContent = ({
? "chat:directoryOperations.didSearchOutsideWorkspace"
: "chat:directoryOperations.didSearch"
}
components={{ code: <code>{tool.regex}</code> }}
components={{ code: <code /> }}
values={{ regex: tool.regex }}
/>
)}
Expand All @@ -732,13 +732,13 @@ export const ChatRowContent = ({
{tool.reason ? (
<Trans
i18nKey="chat:modes.wantsToSwitchWithReason"
components={{ code: <code>{tool.mode}</code> }}
components={{ code: <code /> }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the existing tests pass, would it be worth adding a specific test case that would have caught this infinite recursion bug? This could help prevent regression in the future.

values={{ mode: tool.mode, reason: tool.reason }}
/>
) : (
<Trans
i18nKey="chat:modes.wantsToSwitch"
components={{ code: <code>{tool.mode}</code> }}
components={{ code: <code /> }}
values={{ mode: tool.mode }}
/>
)}
Expand All @@ -748,13 +748,13 @@ export const ChatRowContent = ({
{tool.reason ? (
<Trans
i18nKey="chat:modes.didSwitchWithReason"
components={{ code: <code>{tool.mode}</code> }}
components={{ code: <code /> }}
values={{ mode: tool.mode, reason: tool.reason }}
/>
) : (
<Trans
i18nKey="chat:modes.didSwitch"
components={{ code: <code>{tool.mode}</code> }}
components={{ code: <code /> }}
values={{ mode: tool.mode }}
/>
)}
Expand All @@ -772,7 +772,7 @@ export const ChatRowContent = ({
<span style={{ fontWeight: "bold" }}>
<Trans
i18nKey="chat:subtasks.wantsToCreate"
components={{ code: <code>{tool.mode}</code> }}
components={{ code: <code /> }}
values={{ mode: tool.mode }}
/>
</span>
Expand Down
Loading