Skip to content

Commit 6eaa22d

Browse files
shmuel hizmiclaude
andcommitted
Fix categoryColor crash when name is undefined
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8d8fd6a commit 6eaa22d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages/wmux/src/components/WmuxRoot.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ const CATEGORY_COLORS = [
1414
"#eab308", "#06b6d4", "#f43f5e", "#84cc16", "#a855f7",
1515
];
1616

17-
function categoryColor(name: string): string {
17+
function categoryColor(name: string | undefined): string {
18+
const str = name ?? "default";
1819
let hash = 0;
19-
for (let i = 0; i < name.length; i++) hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
20+
for (let i = 0; i < str.length; i++) hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0;
2021
return CATEGORY_COLORS[Math.abs(hash) % CATEGORY_COLORS.length]!;
2122
}
2223

0 commit comments

Comments
 (0)