Skip to content

fix: address bulk block review comments - #3363

Merged
steebchen merged 2 commits into
mainfrom
claude/bulk-ban-organizations-qx1vff
Aug 1, 2026
Merged

steebchen merged 2 commits into
mainfrom
claude/bulk-ban-organizations-qx1vff

Conversation

@steebchen

@steebchen steebchen commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #3358, which merged before these review-comment fixes could be pushed. Three small robustness fixes; no change to the bulk-block safety guards themselves.

Changes

Share the bulk block limits instead of duplicating them (packages/shared/src/bulk-block.ts)

MIN_BULK_BLOCK_SEARCH_LENGTH and MAX_BULK_BLOCK_ORGANIZATIONS now live in @llmgateway/shared, imported by both the API and the admin dashboard. Previously the UI hard-coded 3 with a comment asking future readers to keep it in sync — if the server value changed, the UI would silently show or hide the bulk action for filters the server disagrees about. The spec imports the shared constant too, so the over-cap test can no longer drift from the real limit.

Don't strand the preview dialog in a loading state (bulk-block-orgs-button.tsx)

handleOpen awaited the preview server action without a try/finally. A rejection (network error, server crash) left previewLoading stuck at true with no error surfaced. Now wrapped, so the loading flag always clears and the error is shown.

Keep the confirmation form usable after a failed block (bulk-block-orgs-button.tsx)

handleConfirm set result unconditionally, which hid the preview and the count input while still rendering an enabled destructive button with a stale confirmationMatches. A second click resubmitted the same stale count. Now result is set only on success; on failure the dialog stays on the confirmation step and re-resolves the preview, so the admin retypes against current numbers. The most likely failure is exactly the 409 the server returns when the set no longer matches the confirmed count, so re-previewing is what makes a retry meaningful.

Testing

apps/api/src/routes/admin-bulk-block.spec.ts — 10/10 passing against merged main. turbo run build --filter=api --filter=admin green.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling for bulk organization blocking.
    • Preview loading now recovers correctly from failures and consistently resets its loading state.
    • Failed bulk-block actions no longer leave stale results and refresh the preview before retrying.
  • Improvements

    • Bulk organization actions now consistently enforce minimum search-length and maximum selection limits.
    • Separate preview and blocking errors provide clearer feedback during bulk actions.

- share MIN/MAX bulk block constants via @llmgateway/shared so the admin
  UI gate cannot drift from what the API enforces
- keep the preview dialog out of a stuck loading state if the preview
  server action rejects
- keep the confirmation form visible after a failed bulk block and
  re-resolve the preview, so a retry confirms against current numbers
  instead of resubmitting a stale count

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SVus1fjS6z6xppaEai34Uj
Copilot AI review requested due to automatic review settings August 1, 2026 18:18
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b46b5be-14fa-4ec8-a4be-ada03443351d

📥 Commits

Reviewing files that changed from the base of the PR and between ee5d0c6 and bbd391f.

📒 Files selected for processing (1)
  • ee/admin/src/components/bulk-block-orgs-button.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • ee/admin/src/components/bulk-block-orgs-button.tsx

Walkthrough

The PR centralizes bulk-block limits in the shared package. The API and admin UI consume these constants. The bulk-block button now tracks preview and block errors separately and reloads preview data after failed operations.

Changes

Bulk-block flow

Layer / File(s) Summary
Shared bulk-block limits
packages/shared/src/bulk-block.ts, packages/shared/src/index.ts
Defines and exports the minimum search length of 3 and maximum organization count of 500.
API validation alignment
apps/api/src/routes/admin.ts, apps/api/src/routes/admin-bulk-block.spec.ts
Uses the shared constants for API validation and test coverage.
Admin bulk-block configuration
ee/admin/src/app/organizations/page.tsx
Uses the shared minimum search length for bulk-action visibility and button configuration.
Preview and failure handling
ee/admin/src/components/bulk-block-orgs-button.tsx
Loads previews through a dedicated function, tracks preview and block errors independently, and reloads preview data after failed bulk-block requests.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Admin as Organizations page
  participant Button as BulkBlockOrgsButton
  participant API as Admin bulk-block API
  Admin->>Button: Open bulk-block dialog
  Button->>API: Load organization preview
  API-->>Button: Return preview or preview error
  Admin->>Button: Confirm bulk block
  Button->>API: Submit bulk-block request
  API-->>Button: Return result or block error
  Button->>API: Reload preview after block error
Loading

Possibly related PRs

🚥 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 identifies this pull request as a fix for review comments related to bulk organization blocking.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/bulk-ban-organizations-qx1vff

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.

❤️ Share

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR is a follow-up robustness pass on the admin “bulk block filtered organizations” feature, focused on preventing UI/server drift for safety limits and improving error/loading handling in the admin confirmation dialog.

Changes:

  • Centralizes bulk-block safety limits (MIN_BULK_BLOCK_SEARCH_LENGTH, MAX_BULK_BLOCK_ORGANIZATIONS) in @llmgateway/shared and updates API, admin UI, and tests to import them.
  • Refactors the admin bulk-block dialog to avoid getting stuck in a loading state when preview fails.
  • Adjusts confirm behavior so the result summary only appears on success, and failures re-preview the current target set.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/shared/src/index.ts Re-exports the new shared bulk-block limit constants.
packages/shared/src/bulk-block.ts Adds shared constants for bulk-block min search length and max org cap.
ee/admin/src/components/bulk-block-orgs-button.tsx Improves preview loading/error handling and confirm flow robustness.
ee/admin/src/app/organizations/page.tsx Uses shared MIN_BULK_BLOCK_SEARCH_LENGTH instead of a local hard-coded value.
apps/api/src/routes/admin.ts Imports shared bulk-block limit constants and removes local duplicates.
apps/api/src/routes/admin-bulk-block.spec.ts Imports shared max-cap constant to prevent test drift.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +74 to +80
try {
const response = await onPreview(trimmedSearch);
if (response.success && response.preview) {
setPreview(response.preview);
} else {
setError(response.error ?? "Failed to preview bulk block");
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in bbd391f, though not by clearing the shared error — that would have broken the other half of this flow. handleConfirm deliberately calls loadPreview() after a failure, so clearing the error on a successful preview would have wiped the block error the reload is meant to accompany.

Split into previewError and blockError instead. loadPreview clears and sets only previewError, so a successful preview drops the stale preview error; the block error survives the reload and both render if they coexist.


Generated by Claude Code

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ee/admin/src/components/bulk-block-orgs-button.tsx`:
- Around line 109-114: Update the exception handling around onBulkBlock in the
bulk-block action to call await loadPreview() after setting the error, matching
the existing resolved-failure path. Ensure rejected requests refresh
preview.blockable before the next confirmation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 99ee324e-8754-44e4-8031-aa3280d883c2

📥 Commits

Reviewing files that changed from the base of the PR and between 27aed99 and ee5d0c6.

📒 Files selected for processing (6)
  • apps/api/src/routes/admin-bulk-block.spec.ts
  • apps/api/src/routes/admin.ts
  • ee/admin/src/app/organizations/page.tsx
  • ee/admin/src/components/bulk-block-orgs-button.tsx
  • packages/shared/src/bulk-block.ts
  • packages/shared/src/index.ts

Comment thread ee/admin/src/components/bulk-block-orgs-button.tsx Outdated
A failed block re-resolves the preview so the admin confirms against current
numbers. With a single error state that reload cleared the block error it was
meant to accompany, so preview and block failures are now tracked separately
and rendered independently.

Also re-resolve the preview when the block request throws: it may have been
applied server-side before the connection failed, leaving preview.blockable
stale for the next confirmation.
@steebchen
steebchen added this pull request to the merge queue Aug 1, 2026
Merged via the queue into main with commit 1b5a083 Aug 1, 2026
12 checks passed
@steebchen
steebchen deleted the claude/bulk-ban-organizations-qx1vff branch August 1, 2026 19:55
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.

3 participants