-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: prevent infinite recursion in Trans components (fixes #6937) #6939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -479,13 +479,13 @@ export const ChatRowContent = ({ | |||||||||
| {tool.path ? ( | ||||||||||
| <Trans | ||||||||||
| i18nKey="chat:codebaseSearch.wantsToSearchWithPath" | ||||||||||
| components={{ code: <code></code> }} | ||||||||||
| components={{ code: <code /> }} | ||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
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 }} | ||||||||||
| /> | ||||||||||
| )} | ||||||||||
|
|
@@ -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 }} | ||||||||||
| /> | ||||||||||
| ) : ( | ||||||||||
|
|
@@ -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 }} | ||||||||||
| /> | ||||||||||
| )} | ||||||||||
|
|
@@ -732,13 +732,13 @@ export const ChatRowContent = ({ | |||||||||
| {tool.reason ? ( | ||||||||||
| <Trans | ||||||||||
| i18nKey="chat:modes.wantsToSwitchWithReason" | ||||||||||
| components={{ code: <code>{tool.mode}</code> }} | ||||||||||
| components={{ code: <code /> }} | ||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }} | ||||||||||
| /> | ||||||||||
| )} | ||||||||||
|
|
@@ -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 }} | ||||||||||
| /> | ||||||||||
| )} | ||||||||||
|
|
@@ -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> | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All instances are covered