Skip to content

fix: Add null guards to SupportersTab pickCount and pickStrategy access#342

Merged
justn-hyeok merged 1 commit intobssm-oss:mainfrom
HuiNeng6:fix/supporters-tab-null-guard
Mar 28, 2026
Merged

fix: Add null guards to SupportersTab pickCount and pickStrategy access#342
justn-hyeok merged 1 commit intobssm-oss:mainfrom
HuiNeng6:fix/supporters-tab-null-guard

Conversation

@HuiNeng6
Copy link
Copy Markdown
Contributor

@HuiNeng6 HuiNeng6 commented Mar 27, 2026

Summary

This PR fixes the missing null guard issue described in Issue #324.

Problem

In SupportersTab.tsx, lines 130 and 193-194 accessed config.supporters.pickCount and config.supporters.pickStrategy without optional chaining, while other lines in the same component used config.supporters?.pool. This inconsistency could cause a crash if config.supporters is undefined.

Solution

Added optional chaining with fallback values:

  • config.supporters?.pickCount ?? 2
  • config.supporters?.pickStrategy ?? 'random'

Changes

  • Line 130: Added ?. and fallback ?? 2
  • Line 193: Added ?. and fallback ?? 2
  • Line 194: Added ?. and fallback ?? 'random'

Testing

  • Code compiles without errors
  • Behavior is consistent with other accesses in the same file

Fixes: #324

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of the supporter configuration settings by adding better handling for cases where configuration data might be missing. The application now gracefully applies default values for pick-count and pick-strategy settings, ensuring the configuration interface remains stable and functional even with incomplete data.

- Use optional chaining for config.supporters?.pickCount
- Use optional chaining for config.supporters?.pickStrategy
- Add fallback values (2 for pickCount, 'random' for pickStrategy)
- Fixes potential crash when config.supporters is undefined

Fixes: #324
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0bebac33-54f5-4377-a47a-dfad50d01eee

📥 Commits

Reviewing files that changed from the base of the PR and between 1b61dac and 5a74afc.

📒 Files selected for processing (1)
  • packages/tui/src/screens/config/SupportersTab.tsx

📝 Walkthrough

Walkthrough

Added optional chaining and nullish coalescing operators to SupportersTab.tsx to safely access config.supporters.pickCount and config.supporters.pickStrategy properties with appropriate default fallbacks, preventing potential undefined reference errors.

Changes

Cohort / File(s) Summary
Null Guard Fix
packages/tui/src/screens/config/SupportersTab.tsx
Added optional chaining (?.) and nullish coalescing (??) operators to three property accesses: pick-count read during edit mode now defaults to 2, pick-count display defaults to 2, and pick-strategy display defaults to 'random'.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A bunny hops through null and void,
Adding guards where crashes wait,
With ?. and ?? deployed,
No more undefined, tempt of fate!
Safe reads and fallbacks bake the cake. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding null guards (optional chaining with fallbacks) to pickCount and pickStrategy access in SupportersTab.tsx.
Linked Issues check ✅ Passed The PR successfully addresses Issue #324 by implementing safe access patterns (optional chaining with fallbacks) for both pickCount and pickStrategy, resolving the null-guard inconsistency.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue requirements: adding null guards to pickCount and pickStrategy access in SupportersTab.tsx at the specified locations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Collaborator

@justn-hyeok justn-hyeok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Clean, minimal fix. Optional chaining + sensible defaults (?? 2, ?? 'random') consistent with existing patterns.

@justn-hyeok justn-hyeok merged commit acb1251 into bssm-oss:main Mar 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: SupportersTab missing null guard on config.supporters.pickCount

2 participants