Repository navigation
fix(sidebar): guard kanban worktree sort against undefined displayName (crash 99657ab1) - #8683
Merged
Merged
Conversation
fix(sidebar): guard kanban worktree sort against undefined displayName (crash 99657ab1) A worktree reached the sidebar with an undefined displayName, so the Manual-sort comparator ran `a.displayName.localeCompare(...)` and threw `TypeError: Cannot read properties of undefined (reading localeCompare)`, unmounting the sidebar.worktrees error boundary. Route both kanban comparators through a null-safe compareDisplayName so a missing name only affects tie-break order instead of crashing. Behavior is unchanged when displayName is present. Adds regression tests for both the manual and recent sort paths. @
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughWorktree sorting now uses a safe display-name comparison helper that falls back to an empty string when displayName is undefined. Both regular and manual sorting use the helper for tie-breaking. Regression tests cover grouping with undefined display names under manual and recent sorting modes. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nwparker
added a commit
that referenced
this pull request
Jul 18, 2026
… (crash 99657ab1) Worktree.displayName is typed non-optional but arrives undefined at runtime for persisted/discovered worktrees (crash 99657ab1). PR #8683 fixed the kanban board; this extends the same guard to the five other sort sites that share those worktree objects — including the Cmd+J switcher (order-empty-query-worktrees) — via one shared compareWorktreeDisplayName helper in lib/. Behavior-neutral when names are present; a missing name now sorts as '' instead of throwing. Co-authored-by: Orca <help@stably.ai>
nwparker
added a commit
that referenced
this pull request
Jul 18, 2026
… (crash 99657ab1) (#9315) * fix(sidebar): guard every worktree sort against undefined displayName (crash 99657ab1) Worktree.displayName is typed non-optional but arrives undefined at runtime for persisted/discovered worktrees (crash 99657ab1). PR #8683 fixed the kanban board; this extends the same guard to the five other sort sites that share those worktree objects — including the Cmd+J switcher (order-empty-query-worktrees) — via one shared compareWorktreeDisplayName helper in lib/. Behavior-neutral when names are present; a missing name now sorts as '' instead of throwing. Co-authored-by: Orca <help@stably.ai> * docs(agents): add over-commenting anti-pattern example to the comment rule Anchors the existing 'document the why, briefly' rule with a concrete before/after (the worktree-displayName guard) so agents stop dumping the crash id, mechanism, file location, and every call site into a comment. Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
6 tasks
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
fix(sidebar): guard kanban worktree sort against undefined displayName (crash 99657ab1) A worktree reached the sidebar with an undefined displayName, so the Manual-sort comparator ran `a.displayName.localeCompare(...)` and threw `TypeError: Cannot read properties of undefined (reading localeCompare)`, unmounting the sidebar.worktrees error boundary. Route both kanban comparators through a null-safe compareDisplayName so a missing name only affects tie-break order instead of crashing. Behavior is unchanged when displayName is present. Adds regression tests for both the manual and recent sort paths. @
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
… (crash 99657ab1) (stablyai#9315) * fix(sidebar): guard every worktree sort against undefined displayName (crash 99657ab1) Worktree.displayName is typed non-optional but arrives undefined at runtime for persisted/discovered worktrees (crash 99657ab1). PR stablyai#8683 fixed the kanban board; this extends the same guard to the five other sort sites that share those worktree objects — including the Cmd+J switcher (order-empty-query-worktrees) — via one shared compareWorktreeDisplayName helper in lib/. Behavior-neutral when names are present; a missing name now sorts as '' instead of throwing. Co-authored-by: Orca <help@stably.ai> * docs(agents): add over-commenting anti-pattern example to the comment rule Anchors the existing 'document the why, briefly' rule with a concrete before/after (the worktree-displayName guard) so agents stop dumping the crash id, mechanism, file location, and every call site into a comment. Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@
Description
Fixes Windows crash report 99657ab1 (react-error-boundary,
boundary_id: sidebar.worktrees), version 1.4.137.A worktree reached the sidebar with an
undefineddisplayName. The kanban lane sort comparator then executeda.displayName.localeCompare(b.displayName)and threw:This unmounted the entire
sidebar.worktreeserror boundary — the sidebar disappeared. Although the report is Windows-only, the bug is cross-platform JS: any worktree with a missingdisplayNametriggers it on any OS.Both kanban comparators (
sortManualBoardWorktreesfor Manual sort,sortBoardWorktreesfor Recent/other sort) share the same unguarded call, so both paths are affected.Fix
Route both comparators through a single null-safe helper:
A missing name now only affects tie-break ordering instead of crashing the sidebar. When
displayNameis present (the overwhelmingly common case),(a.displayName ?? )is identicallya.displayName, so sort order is unchanged.Fix evidence (clear & undeniable)
Regression tests reproduce the exact crash, then verify the fix. The tests force the comparator to actually be reached (equal primary-sort term → falls through to the name tie-break) and give both worktrees an undefined name so the crash is deterministic regardless of V8 sort argument order.
Before the fix (repro confirmed — identical error string to the crash report):
After the fix:
Also verified:
oxlintclean on both files,tsc --noEmit -p config/tsconfig.tc.web.jsonexit 0.ELI5
Orca sorts the workspace cards in the sidebar by name. Sorting compares two names letter-by-letter. One workspace somehow had no name at all (blank/undefined), and asking a blank name to compare itself made the code explode — which knocked out the whole sidebar. Now we treat a missing name as an empty string, so sorting just puts it wherever and keeps calm instead of crashing.
Trade-offs / behavior changes
""(it sorts first alphabetically within its lane) instead of taking down the sidebar. This is strictly better than the crash.displayName(theWorktreetype declares it non-optional) is a separate, larger investigation and is intentionally out of scope for this crash fix.Adversarial review
Two independent adversarial review loops were run to clean:
.localeComparepath; confirmed undefined numeric fields (lastActivityAt,sortOrder) degrade toNaN→falsy tie-break rather than throwing; confirmed the regression tests genuinely reach the comparator and fail-before/pass-after. Result: CLEAN.displayNamemethod calls to check the boundary can't still crash via a different call. Found the list-view sort (smart-sort.ts) and card title (worktree-card-title-display.ts) already guard undefined names; confirmed no unguarded sibling call exists in the boundary's render path. Result: CLEAN.Both loops flagged two non-render-path unguarded
.displayName.localeComparecalls (use-complete-git-repo-add.ts,add-repo-existing-workspaces-telemetry.ts) as pre-existing, separate follow-ups — they run in async/telemetry paths and cannot reproduce this render crash, so they are left out to keep this PR tightly scoped.@