Skip to content

Clean up client filtering after PR #3889#4095

Merged
JAORMX merged 1 commit intomainfrom
cleanup/client-filtering-followup
Mar 12, 2026
Merged

Clean up client filtering after PR #3889#4095
JAORMX merged 1 commit intomainfrom
cleanup/client-filtering-followup

Conversation

@JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented Mar 11, 2026

Summary

PR #3889 added client filtering in thv client setup. Code review identified four mechanical cleanup items — no behavior changes, just improved consistency and safety.

  • Move ErrAllClientsRegistered sentinel from cmd/thv/app/ui/ to pkg/client/ to match project convention (sentinel errors live in pkg/)
  • Replace hand-rolled inner loop with slices.Contains in isClientRegisteredInAllGroups, matching the pattern used in pkg/groups/skills.go
  • Extract selectedGroups() helper to deduplicate the map-to-groups-slice logic shared by filterClientsBySelectedGroups() and RunClientSetup()
  • Add bounds check on group indices before indexing m.Groups to guard against out-of-bounds panics

Type of change

  • Refactoring (no behavior change)

Test plan

  • Unit tests (task test)
  • Linting (task lint-fix)

Changes

File Change
pkg/client/filter.go Add ErrAllClientsRegistered sentinel, use slices.Contains
cmd/thv/app/ui/clients_setup.go Remove local sentinel, extract selectedGroups() with bounds check, use it in filterClientsBySelectedGroups, sortedSelectedGroupNames, and RunClientSetup
cmd/thv/app/client.go Update ui.ErrAllClientsRegisteredclient.ErrAllClientsRegistered
cmd/thv/app/ui/selected_groups_test.go New tests for bounds check and out-of-bounds filtering

Does this introduce a user-facing change?

No

Generated with Claude Code

@github-actions github-actions bot added the size/S Small PR: 100-299 lines changed label Mar 11, 2026
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.62%. Comparing base (0ad68d6) to head (514a072).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4095      +/-   ##
==========================================
+ Coverage   68.56%   68.62%   +0.05%     
==========================================
  Files         448      448              
  Lines       45779    45774       -5     
==========================================
+ Hits        31389    31411      +22     
+ Misses      11967    11943      -24     
+ Partials     2423     2420       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Follow-up to #3889 with four mechanical refactors (no behavior change):

- Replace hand-rolled loop with slices.Contains in isClientRegisteredInAllGroups
- Move ErrAllClientsRegistered sentinel from cmd/thv/app/ui/ to pkg/client/
- Extract selectedGroups() helper to deduplicate map-to-slice logic
- Add bounds check on group indices before indexing m.Groups

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JAORMX JAORMX force-pushed the cleanup/client-filtering-followup branch from a9cf0ea to 514a072 Compare March 11, 2026 12:36
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Mar 11, 2026
@JAORMX JAORMX merged commit 0afd555 into main Mar 12, 2026
45 of 48 checks passed
@JAORMX JAORMX deleted the cleanup/client-filtering-followup branch March 12, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants