fix(locale): prevent titlecase crash on missing session values#604
fix(locale): prevent titlecase crash on missing session values#604Olusammytee wants to merge 1 commit intoKilo-Org:devfrom
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in the Kilo CLI when loading sessions with messages by making the Locale.titlecase function safely handle null and undefined values. The issue occurred when attempting to sync sessions between VS Code KiloCode and Kilo CLI, where legacy or incomplete message fields could cause the function to crash with a "str3.replace is not an object" error.
Changes:
- Modified the
titlecasefunction signature to accept optional and nullable string parameters (string | null | undefined) - Added a guard clause to return an empty string for falsy input values, preventing the crash when
.replace()is called on null/undefined
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function titlecase(str?: string | null) { | ||
| if (!str) return "" |
There was a problem hiding this comment.
The new null/undefined handling behavior for the titlecase function is not covered by tests. Consider adding test cases to verify the function correctly returns an empty string when passed undefined, null, or empty string values. This would prevent regression and document the intended behavior.
Summary
ull values
eplace
Fixes #310