mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
fix: 修复 truncate 函数接收到 undefined/null 时崩溃的问题
BackgroundTask 组件渲染时传入的 task 属性(description、title、command 等)
可能为 undefined,导致 str.indexOf('\n') 抛出 TypeError。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -132,10 +132,11 @@ export function truncateToWidthNoEllipsis(
|
||||
* @returns The truncated string with ellipsis if needed
|
||||
*/
|
||||
export function truncate(
|
||||
str: string,
|
||||
str: string | undefined | null,
|
||||
maxWidth: number,
|
||||
singleLine: boolean = false,
|
||||
): string {
|
||||
if (str == null) return ''
|
||||
let result = str
|
||||
|
||||
// If singleLine is true, truncate at first newline
|
||||
|
||||
Reference in New Issue
Block a user