Skip to content

fix(web/default/playground): remove hardcoded 'auto' group default and injection - #4799

Closed
xinnyu wants to merge 1 commit into
QuantumNous:mainfrom
xinnyu:fix/playground-auto-group-default
Closed

xinnyu wants to merge 1 commit into
QuantumNous:mainfrom
xinnyu:fix/playground-auto-group-default

Conversation

@xinnyu

@xinnyu xinnyu commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Context

This is the same class of bug as #4796 (auto group injection in API key form), but in the Playground feature. Found while testing #4796 — the API key dropdown was fixed but the Playground still showed 'auto' as the default selected group and users couldn't chat.

Problem

The Playground hardcodes 'auto' as the group at two layers:

1. constants.ts — initial config

export const DEFAULT_GROUP = 'auto' as const

export const DEFAULT_CONFIG: PlaygroundConfig = {
  model: 'gpt-4o',
  group: DEFAULT_GROUP,  // <- every new visit starts here
  ...
}

Every new visitor opens the Playground with config.group = 'auto' selected.

2. index.tsx — group dropdown population

useEffect(() => {
  if (!groupsData) return
  const hasAutoGroup = groupsData.some((g) => g.value === DEFAULT_GROUP)
  const processedGroups = hasAutoGroup
    ? groupsData
    : [
        { value: DEFAULT_GROUP, label: 'Auto', ratio: 1, desc: 'Circuit Breaker' },
        ...groupsData,
      ]
  setGroups(processedGroups)
}, [groupsData, setGroups])

If the backend doesn't return 'auto' (because the operator didn't configure AutoGroups in system options — setting/auto_group.go), the frontend forcibly injects it.

Effect

For operators who never configured AutoGroups (the default state), users see 'auto' as the default selected option in the Playground group dropdown. Clicking Send routes to the 'auto' group, which has no upstream channels mapped, so the request silently fails to route. From the user's perspective the Playground is broken — typing a message and hitting send does nothing.

Fix

  1. Change DEFAULT_GROUP from 'auto' to 'default' — the standard user group that every install ships with via setting/user_usable_group.go's defaults.
  2. Remove the unconditional auto-injection. The dropdown should show exactly what GET /api/user/self/groups returns, no more.
  3. Add a migration fallback: if config.group (loaded from localStorage) isn't in the backend-returned groups, switch to DEFAULT_GROUP or the first available group. Mirrors the existing pattern in the same useEffect block for config.model validation. This handles returning users whose localStorage retained 'auto' from before this fix.

Verification

  • New visitor (no localStorage): lands on 'default' group, chat works immediately
  • Returning visitor with config.group = 'auto' in localStorage: on next visit, fallback kicks in, group migrates to 'default' (or whatever the user's actual default is), chat works
  • Returning visitor with config.group = 'somegroup' that's still configured: no change, keeps using that group
  • Operator who DOES configure 'auto' via UserUsableGroups + AutoGroups: 'auto' shows up in the dropdown normally via the backend response, selectable and functional

No backend changes required. Pure frontend bugfix.

Summary by CodeRabbit

Bug Fixes

  • Updated the default group selection in the playground to use 'default' instead of 'auto'
  • Improved group fallback mechanism to gracefully handle cases where previously saved group configurations are no longer available, automatically selecting the default or first available group

Review Change Stack

…d injection

Playground has the same hardcoded-'auto'-group pattern that PR QuantumNous#4796 fixed
in the API key form, but in two places:

1. `constants.ts:DEFAULT_GROUP = 'auto'` — initial config value for new visitors
2. `index.tsx:useEffect` — unconditionally injects an 'auto' option into the
   groups list returned by GET /api/user/self/groups when 'auto' isn't there

Effect: every install showed 'auto' as the default selected group in the
Playground. For operators who haven't configured AutoGroups in system options,
selecting 'auto' silently fails to route any request — clicking Send produces
no response, breaking the chat experience entirely. The user perceives the
Playground as broken.

Fix:
- Change `DEFAULT_GROUP` to `'default'` (the standard built-in user group)
- Remove the unconditional auto-injection
- Add a migration fallback: if the persisted config.group isn't in the
  groups returned by the backend (e.g. a returning user whose localStorage
  retained 'auto' from a previous version), switch to DEFAULT_GROUP or the
  first available group. Mirrors the existing pattern for `config.model`
  validation in the same useEffect block.

Verified locally: existing localStorage value of 'auto' migrates cleanly to
the user's actual default group on next visit. New visitors land on the
backend-supplied default group and can chat immediately.
@coderabbitai

coderabbitai Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d72fe670-b823-437e-b14c-0849e3026fe5

📥 Commits

Reviewing files that changed from the base of the PR and between 19fc384 and 2d6688d.

📒 Files selected for processing (2)
  • web/default/src/features/playground/constants.ts
  • web/default/src/features/playground/index.tsx

Walkthrough

The playground's group selection logic is refactored to use 'default' as the safe default instead of 'auto', which requires specific operator configuration. The effect that loads groups now validates the persisted group choice against the returned groups and falls back to the new DEFAULT_GROUP constant when needed.

Changes

Playground group selection refactoring

Layer / File(s) Summary
Default group constant and documentation
web/default/src/features/playground/constants.ts
DEFAULT_GROUP is changed from 'auto' to 'default' with expanded inline documentation explaining that 'auto' requires AutoGroups operator configuration.
Group validation and fallback logic
web/default/src/features/playground/index.tsx
The groups update effect now sets groups directly and validates the persisted config.group against the returned groups. When invalid, it falls back to DEFAULT_GROUP if available or the first available group, then updates config via updateConfig.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hops through groups with care,
From 'auto' lost, to 'default' fair,
When config fails, we fall back swift,
To defaults that don't cause a rift,
Playground paths now clear and bright! 🐰✨

🚥 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 describes the main changes: removing hardcoded 'auto' group default and injection logic from the playground component.
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.

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

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

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.

Calcium-Ion added a commit that referenced this pull request May 12, 2026
* fix: theme-aware payment paths, auto-group validation, route guards, perf group filtering

- Add common.ThemeAwarePath to generate correct redirect URLs based on
  active theme (default vs classic), replacing hardcoded /console/* paths
  in 7 controllers and service/quota.go (#4765)
- Validate auto-group availability against getUserGroups before defaulting
  form values; playground falls back to 'default' group when 'auto' is
  unavailable (#4796, #4799)
- Enforce HeaderNavModules settings in rankings route (frontend + backend
  API) and SidebarModulesAdmin in playground route to block direct URL
  access when features are disabled (#4704, #4512)
- Filter perf_metrics API response to only include currently configured
  groups, hiding stale data from deleted groups (#4790)
- Preserve query params (pay=success/fail) in /console/topup → /wallet
  frontend redirect

* fix: update hero section text and localization strings for clarity
@xinnyu

xinnyu commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

Closing — the bug has been addressed by #4802 ("fix: defaut ui triage") which not only removes the unconditional 'auto' injection but also adds a graceful fallback when the persisted group value isn't in the available groups returned by the backend. Cleaner solution than mine. Thanks!

@xinnyu xinnyu closed this May 12, 2026
@xinnyu
xinnyu deleted the fix/playground-auto-group-default branch May 13, 2026 06:57
xyfacai pushed a commit to xyfacai/new-api that referenced this pull request May 30, 2026
* fix: theme-aware payment paths, auto-group validation, route guards, perf group filtering

- Add common.ThemeAwarePath to generate correct redirect URLs based on
  active theme (default vs classic), replacing hardcoded /console/* paths
  in 7 controllers and service/quota.go (QuantumNous#4765)
- Validate auto-group availability against getUserGroups before defaulting
  form values; playground falls back to 'default' group when 'auto' is
  unavailable (QuantumNous#4796, QuantumNous#4799)
- Enforce HeaderNavModules settings in rankings route (frontend + backend
  API) and SidebarModulesAdmin in playground route to block direct URL
  access when features are disabled (QuantumNous#4704, QuantumNous#4512)
- Filter perf_metrics API response to only include currently configured
  groups, hiding stale data from deleted groups (QuantumNous#4790)
- Preserve query params (pay=success/fail) in /console/topup → /wallet
  frontend redirect

* fix: update hero section text and localization strings for clarity
SamuelSxy pushed a commit to SamuelSxy/new-api-rh that referenced this pull request Jun 7, 2026
* fix: theme-aware payment paths, auto-group validation, route guards, perf group filtering

- Add common.ThemeAwarePath to generate correct redirect URLs based on
  active theme (default vs classic), replacing hardcoded /console/* paths
  in 7 controllers and service/quota.go (QuantumNous#4765)
- Validate auto-group availability against getUserGroups before defaulting
  form values; playground falls back to 'default' group when 'auto' is
  unavailable (QuantumNous#4796, QuantumNous#4799)
- Enforce HeaderNavModules settings in rankings route (frontend + backend
  API) and SidebarModulesAdmin in playground route to block direct URL
  access when features are disabled (QuantumNous#4704, QuantumNous#4512)
- Filter perf_metrics API response to only include currently configured
  groups, hiding stale data from deleted groups (QuantumNous#4790)
- Preserve query params (pay=success/fail) in /console/topup → /wallet
  frontend redirect

* fix: update hero section text and localization strings for clarity
fx247562340 pushed a commit to fx247562340/vancine-platform that referenced this pull request Jun 11, 2026
* fix: theme-aware payment paths, auto-group validation, route guards, perf group filtering

- Add common.ThemeAwarePath to generate correct redirect URLs based on
  active theme (default vs classic), replacing hardcoded /console/* paths
  in 7 controllers and service/quota.go (QuantumNous#4765)
- Validate auto-group availability against getUserGroups before defaulting
  form values; playground falls back to 'default' group when 'auto' is
  unavailable (QuantumNous#4796, QuantumNous#4799)
- Enforce HeaderNavModules settings in rankings route (frontend + backend
  API) and SidebarModulesAdmin in playground route to block direct URL
  access when features are disabled (QuantumNous#4704, QuantumNous#4512)
- Filter perf_metrics API response to only include currently configured
  groups, hiding stale data from deleted groups (QuantumNous#4790)
- Preserve query params (pay=success/fail) in /console/topup → /wallet
  frontend redirect

* fix: update hero section text and localization strings for clarity
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
* fix: theme-aware payment paths, auto-group validation, route guards, perf group filtering

- Add common.ThemeAwarePath to generate correct redirect URLs based on
  active theme (default vs classic), replacing hardcoded /console/* paths
  in 7 controllers and service/quota.go (QuantumNous#4765)
- Validate auto-group availability against getUserGroups before defaulting
  form values; playground falls back to 'default' group when 'auto' is
  unavailable (QuantumNous#4796, QuantumNous#4799)
- Enforce HeaderNavModules settings in rankings route (frontend + backend
  API) and SidebarModulesAdmin in playground route to block direct URL
  access when features are disabled (QuantumNous#4704, QuantumNous#4512)
- Filter perf_metrics API response to only include currently configured
  groups, hiding stale data from deleted groups (QuantumNous#4790)
- Preserve query params (pay=success/fail) in /console/topup → /wallet
  frontend redirect

* fix: update hero section text and localization strings for clarity
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
* fix: theme-aware payment paths, auto-group validation, route guards, perf group filtering

- Add common.ThemeAwarePath to generate correct redirect URLs based on
  active theme (default vs classic), replacing hardcoded /console/* paths
  in 7 controllers and service/quota.go (QuantumNous#4765)
- Validate auto-group availability against getUserGroups before defaulting
  form values; playground falls back to 'default' group when 'auto' is
  unavailable (QuantumNous#4796, QuantumNous#4799)
- Enforce HeaderNavModules settings in rankings route (frontend + backend
  API) and SidebarModulesAdmin in playground route to block direct URL
  access when features are disabled (QuantumNous#4704, QuantumNous#4512)
- Filter perf_metrics API response to only include currently configured
  groups, hiding stale data from deleted groups (QuantumNous#4790)
- Preserve query params (pay=success/fail) in /console/topup → /wallet
  frontend redirect

* fix: update hero section text and localization strings for clarity
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