Skip to content

proxy-min-max-limit-display#1929

Merged
ragnep merged 3 commits intomainfrom
rep-nic-limit-changes
Feb 13, 2026
Merged

proxy-min-max-limit-display#1929
ragnep merged 3 commits intomainfrom
rep-nic-limit-changes

Conversation

@ragnep
Copy link
Copy Markdown
Contributor

@ragnep ragnep commented Feb 13, 2026

Summary by CodeRabbit

  • New Features

    • Added an error toast when CIC rate updates fail.
  • Bug Fixes

    • Skip min/max enforcement and validation when acting via an active profile proxy to avoid erroneous clamping.
    • Simplified CIC and Rep displays in proxy mode: removed duplicate max/min lines and streamlined available-rating messaging, including removal of the prior proxy “no rep left” message.

Signed-off-by: ragnep <ragneinfo@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

Early-exit guards were added to value normalization/validation to bypass min/max logic when activeProfileProxy is present; UI rendering was simplified to hide separate min lines and show a single +/- max line in non-proxy scenarios across CIC and Rep components.

Changes

Cohort / File(s) Summary
CIC Rate Components
components/user/identity/header/cic-rate/UserPageIdentityHeaderCICRate.tsx, components/user/identity/header/cic-rate/UserPageIdentityHeaderCICRateStats.tsx
Added early-return guards in adjustStrValueToMinMax and getIsValidValue to no-op when activeProfileProxy exists; removed proxy-specific NIC detail lines and consolidated non-proxy display to a single +/- max NIC rating line.
Rep Modify Components
components/user/rep/modify-rep/UserPageRepModifyModal.tsx, components/user/rep/modify-rep/UserPageRepModifyModalRaterStats.tsx
Added early-return guards in adjustStrValueToMinMax and getIsValidValue to skip min/max enforcement when activeProfileProxy exists; removed separate min/max Rep display for proxy cases and consolidated non-proxy display to a single +/- max Rep line.
Rep New-Search Header
components/user/rep/new-rep/UserPageRepNewRepSearchHeader.tsx
Removed CommonInfoBox import and the proxy-specific "no rep left" message branch; now only renders available Rep block when not acting as a proxy.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • simo6529

Poem

🐇 I nudged a guard, then hopped away,
When proxies sit, the bounds won’t stay.
Parts made simple, one plus-or-minus sign,
Soft thumps of code — the UI’s fine. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'proxy-min-max-limit-display' is directly related to the main changes in the PR, which involve modifying min/max value handling and limit displays when an active profile proxy exists.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rep-nic-limit-changes

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
components/user/rep/modify-rep/UserPageRepModifyModal.tsx (1)

260-273: ⚠️ Potential issue | 🟡 Minor

Proxy users get no client-side bounds feedback before submission.

With both adjustStrValueToMinMax (no-op) and getIsValidValue (always true) short-circuited for proxy, there's zero client-side guardrail. A proxy user can type an arbitrarily large value, see no red ring or clamping, and only discover the value is rejected on server response (toast error at Line 374). Consider at least keeping getIsValidValue functional for proxy so the input ring turns red, even if you skip the on-blur clamping.

components/user/identity/header/cic-rate/UserPageIdentityHeaderCICRate.tsx (1)

187-217: ⚠️ Potential issue | 🟡 Minor

Same concern as in UserPageRepModifyModal.tsx — no client-side validation for proxy users.

Both guards mirror the Rep modal pattern. Same risk: proxy users get no visual feedback for out-of-range values until server rejection. Consider keeping validation active while only skipping the on-blur clamping.

Signed-off-by: ragnep <ragneinfo@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
components/user/rep/modify-rep/UserPageRepModifyModalRaterStats.tsx (1)

81-83: ⚠️ Potential issue | 🔴 Critical

The display "+/- {max}" assumes min === -max, but this invariant does not consistently hold.

The label says "Your max/min Rep Rating" but renders only the max value with a +/- prefix. In the non-proxy case, this assumption only holds when currentRep === 0. In the proxy case, minProxyRep = currentRep - proxyAvailableCredit and maxProxyRep = currentRep + proxyAvailableCredit use independent calculations. When currentRep ≠ 0, the min and max are asymmetric, making the +/- notation misleading.

🧹 Nitpick comments (1)
components/user/rep/modify-rep/UserPageRepModifyModalRaterStats.tsx (1)

71-86: Merge the two adjacent !activeProfileProxy guards into a single fragment.

Both blocks share the same condition and are siblings inside the same flex container. Wrapping them in a single React.Fragment reduces duplication of the guard check.

♻️ Suggested consolidation
-        {!activeProfileProxy && (
-          <span className="tw-text-sm tw-block tw-text-iron-300 tw-font-normal">
-            <span>Your available Rep:</span>
-            <span className="tw-ml-1 tw-font-semibold tw-text-iron-50">
-              {formatNumberWithCommas(availableCredit)}
-            </span>
-          </span>
-        )}
-        {!activeProfileProxy && (
-          <span className="tw-text-sm tw-block tw-text-iron-300 tw-font-normal">
-            <span>Your max/min Rep Rating to {repState.category}:</span>
-            <span className="tw-ml-1 tw-font-semibold tw-text-iron-50">
-              +/- {formatNumberWithCommas(minMaxValues.max)}
-            </span>
-          </span>
-        )}
+        {!activeProfileProxy && (
+          <>
+            <span className="tw-text-sm tw-block tw-text-iron-300 tw-font-normal">
+              <span>Your available Rep:</span>
+              <span className="tw-ml-1 tw-font-semibold tw-text-iron-50">
+                {formatNumberWithCommas(availableCredit)}
+              </span>
+            </span>
+            <span className="tw-text-sm tw-block tw-text-iron-300 tw-font-normal">
+              <span>Your max/min Rep Rating to {repState.category}:</span>
+              <span className="tw-ml-1 tw-font-semibold tw-text-iron-50">
+                +/- {formatNumberWithCommas(minMaxValues.max)}
+              </span>
+            </span>
+          </>
+        )}

Signed-off-by: ragnep <ragneinfo@gmail.com>
@ragnep ragnep merged commit b237031 into main Feb 13, 2026
5 of 6 checks passed
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@components/user/identity/header/cic-rate/UserPageIdentityHeaderCICRate.tsx`:
- Around line 85-90: The onError handler currently casts error unsafely to
string; change it to produce a safe human-readable message before calling
setToast: in the onError callback (the onError passed to commonApiPost/related
call), compute message = typeof error === "string" ? error : error instanceof
Error ? error.message : (() => { try { return JSON.stringify(error); } catch {
return String(error); } })(); then call setToast({ message, type: "error" });
This ensures Error objects, plain objects, and other types render usefully in
the toast.

Comment on lines +85 to +90
onError: (error) => {
setToast({
message: error as unknown as string,
type: "error",
});
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's find the commonApiPost function definition
rg -n "commonApiPost" --type=ts --type=tsx -B 2 -A 10 | head -50

Repository: 6529-Collections/6529seize-frontend

Length of output: 106


🏁 Script executed:

# Look for the actual API error throwing patterns
fd -e ts -e tsx | xargs rg "throw new Error|reject|throw " -B 1 -A 1 | grep -i "common\|api\|error" | head -30

Repository: 6529-Collections/6529seize-frontend

Length of output: 3180


🏁 Script executed:

# Check how other onError handlers cast errors in the codebase
rg "onError.*=>" --type=tsx --type=ts -A 3 | head -50

Repository: 6529-Collections/6529seize-frontend

Length of output: 106


🏁 Script executed:

# Let's also check the specific file context around lines 85-90
cat -n "components/user/identity/header/cic-rate/UserPageIdentityHeaderCICRate.tsx" | sed -n '70,100p'

Repository: 6529-Collections/6529seize-frontend

Length of output: 1106


🏁 Script executed:

# Search for commonApiPost definition
rg "export.*commonApiPost|function commonApiPost|const commonApiPost" -t ts

Repository: 6529-Collections/6529seize-frontend

Length of output: 1385


🏁 Script executed:

# Also search for where commonApiPost is imported/used in this file
rg "commonApiPost" "components/user/identity/header/cic-rate/UserPageIdentityHeaderCICRate.tsx" -B 2 -A 2

Repository: 6529-Collections/6529seize-frontend

Length of output: 402


🏁 Script executed:

# Check for similar mutation patterns with onError in this codebase
rg "useMutation.*onError" -t ts -A 5 | head -60

Repository: 6529-Collections/6529seize-frontend

Length of output: 61


🏁 Script executed:

# Look at the imports in the UserPageIdentityHeaderCICRate.tsx file to understand what mutation is being used
head -30 "components/user/identity/header/cic-rate/UserPageIdentityHeaderCICRate.tsx"

Repository: 6529-Collections/6529seize-frontend

Length of output: 1319


🏁 Script executed:

# Read the commonApiPost implementation
cat -n "services/api/common-api.ts" | head -100

Repository: 6529-Collections/6529seize-frontend

Length of output: 3480


🏁 Script executed:

# Get more context on commonApiPost, especially error handling
rg "export const commonApiPost" -A 30 "services/api/common-api.ts"

Repository: 6529-Collections/6529seize-frontend

Length of output: 1531


Unsafe error-to-string cast may produce [object Object] in the toast on edge cases.

error as unknown as string will display correctly when commonApiPost rejects with a string (the normal path via handleApiError), but fails when it throws an Error object (e.g., JSON parse failures, network errors). In those cases, the toast will show [object Object].

Suggested fix
    onError: (error) => {
      setToast({
-       message: error as unknown as string,
+       message: error instanceof Error ? error.message : String(error),
         type: "error",
       });
    },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onError: (error) => {
setToast({
message: error as unknown as string,
type: "error",
});
},
onError: (error) => {
setToast({
message: error instanceof Error ? error.message : String(error),
type: "error",
});
},
🤖 Prompt for AI Agents
In `@components/user/identity/header/cic-rate/UserPageIdentityHeaderCICRate.tsx`
around lines 85 - 90, The onError handler currently casts error unsafely to
string; change it to produce a safe human-readable message before calling
setToast: in the onError callback (the onError passed to commonApiPost/related
call), compute message = typeof error === "string" ? error : error instanceof
Error ? error.message : (() => { try { return JSON.stringify(error); } catch {
return String(error); } })(); then call setToast({ message, type: "error" });
This ensures Error objects, plain objects, and other types render usefully in
the toast.

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.

2 participants