Skip to content

Explain model recommendation badges#5

Merged
dzarlax merged 1 commit into
mainfrom
codex/explain-recommendation-badges
Jun 15, 2026
Merged

Explain model recommendation badges#5
dzarlax merged 1 commit into
mainfrom
codex/explain-recommendation-badges

Conversation

@dzarlax

@dzarlax dzarlax commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add shared display labels for model recommendation status, policy, and primary reasons.
  • Update Telegram Mini App and full admin rows to avoid duplicate Recommended badges.
  • Add regressions for recommended and free candidate display metadata.

Test Plan

  • go test -count=1 ./internal/adminapi
  • go test -count=1 ./...

Summary by CodeRabbit

  • New Features

    • Enhanced model display in admin interface with improved status and policy label organization.
    • Structured recommendation reasoning with primary and secondary reason fields for clearer model guidance.
  • Bug Fixes

    • Refined validation for recommended model display, ensuring proper suppression of redundant policy information.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@dzarlax, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 48 minutes and 28 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b2eb2050-fdeb-4aa8-b015-8ad35a4eec92

📥 Commits

Reviewing files that changed from the base of the PR and between 09a3ce2 and 1732c0d.

📒 Files selected for processing (7)
  • internal/adminapi/adminapi_test.go
  • internal/adminapi/handlers.go
  • internal/adminapi/model_display.go
  • internal/adminapi/recommend_test.go
  • internal/adminapi/templates/partials_models_row.html
  • internal/adminapi/templates/tg_admin.html
  • internal/adminapi/tgadmin.go
📝 Walkthrough

Walkthrough

Adds four computed display fields (StatusLabel, PolicyLabel, PrimaryReason, SecondaryReasons) to model UI representations. A new model_display.go file centralizes the computation logic. uiModel and tgAdminModel structs are extended with these fields, decoration calls are inserted into both handler paths and tgModelFromUI, both HTML templates are updated to render the new fields, and tests are added covering deduplication and label correctness.

Changes

Model Display Label and Reason Fields

Layer / File(s) Summary
Display field computation logic
internal/adminapi/model_display.go
New file defines modelDisplay struct and all helper functions: decorateModelDisplay, applyModelDisplay, modelDisplayFor, modelStatusLabel, modelPolicyLabel, modelPrimaryReason, modelSecondaryReasons, and firstNonEmpty.
uiModel and tgAdminModel extension + wiring
internal/adminapi/handlers.go, internal/adminapi/tgadmin.go
uiModel gains four display fields; decorateModelDisplay is called in both the preset and browse handler paths; tgAdminModel struct gets matching JSON fields; tgModelFromUI accepts role, derives currentModel, and calls applyModelDisplay.
Template rendering
internal/adminapi/templates/partials_models_row.html, internal/adminapi/templates/tg_admin.html
partials_models_row.html replaces .Section/.Policy/.Reasons with .StatusLabel/.PolicyLabel/.PrimaryReason/.SecondaryReasons; tg_admin.html replaces chip derivation and reason note logic with the new pre-computed fields.
Tests
internal/adminapi/recommend_test.go, internal/adminapi/adminapi_test.go
TestModelDisplayDedupesRecommendedInternals verifies modelDisplayFor deduplication; containsString helper added; TestTGAdminRecommendedModelsAppendFreeCandidatesUnrecommended gains PrimaryReason and PolicyLabel assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 A rabbit hopped through model land,
Labels and reasons close at hand.
"StatusLabel here, PolicyLabel there!"
No duplicates — the warren's fair.
PrimaryReason leads the way,
Secondary thoughts in neat array. 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Explain model recommendation badges' directly reflects the PR's core objective of introducing display labels and explanations for model recommendation badges, which is the primary focus of the changeset.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/explain-recommendation-badges

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09a3ce22ad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/adminapi/model_display.go Outdated
Comment on lines +43 to +47
switch modelSectionKey(m) {
case "recommended":
return "Recommended"
case "interesting":
return "Interesting"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve candidate status for catalog results

For non-preset catalog/search results, annotateModelForRole leaves Section empty and sets Policy to candidate; calling modelSectionKey here falls through to that helper's default "interesting", so every ordinary model in the full browser and Telegram search now renders an Interesting badge while the new template suppresses the raw candidate policy. This makes the recommendation bucket label appear on plain catalog candidates; distinguish an explicit section/source from the helper's bucket fallback before choosing the display status.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
internal/adminapi/model_display.go (1)

61-84: ⚡ Quick win

Redundant if-else blocks in modelPolicyLabel.

Lines 62-65, 66-70, 71-76, and 80-84 all contain if-else blocks where both branches return the same value. For example:

case "manual_allow":
    if status == "Interesting" {
        return "Manual allow"
    }
    return "Manual allow"

This pattern repeats for manual_deny, free_unverified, and free_blocked. The conditions check whether the status already conveys the policy (e.g., manual_allow + Interesting), suggesting deduplication was intended, but both branches return the same label.

Either:

  1. The if-branch should return "" to suppress duplicate labels (matching the deduplication for "recommended" on line 59), or
  2. The if conditions are vestigial and should be removed for clarity.

Since tests only verify suppression for "recommended" policy and expect other policy labels to be shown (e.g., PolicyLabel="Free unverified" in adminapi_test.go:433), the conditions appear unnecessary.

♻️ Proposed fix to remove redundant conditions
 case "manual_allow":
-    if status == "Interesting" {
-        return "Manual allow"
-    }
     return "Manual allow"
 case "manual_deny":
-    if status == "Blocked" {
-        return "Manual deny"
-    }
     return "Manual deny"
 case "free_unverified":
-    if status == "Untested" {
-        return "Free unverified"
-    }
     return "Free unverified"
 case "free_verified":
     return "Free verified"
 case "free_degraded":
     return "Free degraded"
 case "free_blocked":
-    if status == "Blocked" {
-        return "Free blocked"
-    }
     return "Free blocked"
🤖 Prompt for 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.

In `@internal/adminapi/model_display.go` around lines 61 - 84, The
modelPolicyLabel function contains redundant if-else blocks in the cases for
manual_allow, manual_deny, free_unverified, and free_blocked where both the
if-branch and else-branch return the same value. Since tests expect these policy
labels to always be displayed and both branches are identical, remove the
unnecessary conditional checks. For each of these four case statements, replace
the if-else block with a single direct return statement that returns the label
value immediately, matching the simpler pattern already used in the
free_verified and free_degraded cases.
🤖 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.

Nitpick comments:
In `@internal/adminapi/model_display.go`:
- Around line 61-84: The modelPolicyLabel function contains redundant if-else
blocks in the cases for manual_allow, manual_deny, free_unverified, and
free_blocked where both the if-branch and else-branch return the same value.
Since tests expect these policy labels to always be displayed and both branches
are identical, remove the unnecessary conditional checks. For each of these four
case statements, replace the if-else block with a single direct return statement
that returns the label value immediately, matching the simpler pattern already
used in the free_verified and free_degraded cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c56b8343-7d69-4132-b4ab-fe3bd71f69a4

📥 Commits

Reviewing files that changed from the base of the PR and between 1e44740 and 09a3ce2.

📒 Files selected for processing (7)
  • internal/adminapi/adminapi_test.go
  • internal/adminapi/handlers.go
  • internal/adminapi/model_display.go
  • internal/adminapi/recommend_test.go
  • internal/adminapi/templates/partials_models_row.html
  • internal/adminapi/templates/tg_admin.html
  • internal/adminapi/tgadmin.go

@dzarlax dzarlax force-pushed the codex/explain-recommendation-badges branch from 09a3ce2 to 1732c0d Compare June 15, 2026 15:54
@dzarlax dzarlax merged commit 8a2fae8 into main Jun 15, 2026
6 checks passed
@dzarlax dzarlax deleted the codex/explain-recommendation-badges branch June 15, 2026 16:05
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.

1 participant