show the fairness reserve toggle only when it can matter (#12557)

* feat: show the fairness reserve toggle only when workspace fairness is on or the group is a reserve

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjsYvvJe56H5vnK7jXVvAp

* fix: drop the fairness-off warning once the reserve is switched off in the drawer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjsYvvJe56H5vnK7jXVvAp

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-11-20 09:07:44 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 666f3e5577
commit b08a2aada1
3 changed files with 42 additions and 9 deletions
+3
View File
@@ -1519,6 +1519,9 @@ pub async fn get_global_setting(
// would be refused, and they are usually not a superadmin. Not a secret: pointing
// any MCP client at the instance discovers the same answer.
&& key != MCP_DISABLE_TOKEN_QUERY_PARAM_SETTING
// A devops editing a worker group reads it to know whether a fairness reserve would
// ever pull a job.
&& key != WORKSPACE_FAIRNESS_ENABLED_SETTING
{
require_super_admin(&db, &authed).await?;
}
+22 -8
View File
@@ -232,6 +232,8 @@
workers: [string, WorkerPing[]][]
isAgent?: boolean
defaultTagPerWorkspace?: boolean | undefined
/** undefined while unknown: the reserve toggle then stays shown */
workspaceFairnessEnabled?: boolean | undefined
width: number
shouldAutoOpenDrawer?: boolean
onDrawerOpened?: () => void
@@ -248,6 +250,7 @@
workers,
isAgent = false,
defaultTagPerWorkspace = undefined,
workspaceFairnessEnabled = undefined,
width = 0,
shouldAutoOpenDrawer = false,
onDrawerOpened = () => {},
@@ -943,7 +946,7 @@
disabled={!canEditConfig}
/>
</Label>
{#if !isAgent}
{#if !isAgent && (workspaceFairnessEnabled !== false || config?.fairness_reserve === true)}
<div class="mt-8"></div>
<Label label="Fairness reserve" eeOnly={!hasEnterpriseFeatures}>
{#snippet header()}
@@ -967,10 +970,17 @@
}}
disabled={!canEditEEConfig}
/>
<p class="text-2xs text-secondary">
Idle until a workspace is capped. Requires workspace fairness to be enabled in the
instance settings, otherwise the group never pulls a job.
</p>
{#if workspaceFairnessEnabled === false && nconfig?.fairness_reserve === true}
<Alert size="xs" type="warning" title="Workspace fairness is off">
This group pulls no jobs while workspace fairness is off in the instance settings.
Turn the reserve off, or enable workspace fairness.
</Alert>
{:else}
<p class="text-2xs text-secondary">
Idle until a workspace is capped. Requires workspace fairness to be enabled in the
instance settings, otherwise the group never pulls a job.
</p>
{/if}
</Label>
{/if}
<div class="mt-8"></div>
@@ -1561,12 +1571,16 @@
</Badge>
{/if}
{#if config?.fairness_reserve === true && !isAgent}
<Badge color="indigo" small>
<Badge color={workspaceFairnessEnabled === false ? 'yellow' : 'indigo'} small>
Fairness reserve
<Tooltip>
{#snippet text()}
Pulls jobs only while workspace fairness caps a workspace, and then only jobs of the
workspaces it does not cap. Idle otherwise.
{#if workspaceFairnessEnabled === false}
Workspace fairness is off in the instance settings, so this group pulls no jobs.
{:else}
Pulls jobs only while workspace fairness caps a workspace, and then only jobs of
the workspaces it does not cap. Idle otherwise.
{/if}
{/snippet}
</Tooltip>
</Badge>
@@ -50,7 +50,7 @@
import YAML from 'yaml'
import { cleanWorkerGroupConfig } from '$lib/components/worker_group'
import { DEFAULT_TAGS_WORKSPACES_SETTING } from '$lib/consts'
import { DEFAULT_TAGS_WORKSPACES_SETTING, WORKSPACE_FAIRNESS_ENABLED_SETTING } from '$lib/consts'
import AutoscalingEvents from '$lib/components/AutoscalingEvents.svelte'
import HttpAgentWorkerDrawer from '$lib/components/HttpAgentWorkerDrawer.svelte'
import WorkerRepl from '$lib/components/WorkerRepl.svelte'
@@ -575,10 +575,24 @@
let newGroupPopover: Popover | undefined = $state(undefined)
let workspaceFairnessEnabled: boolean | undefined = $state(undefined)
async function loadWorkspaceFairnessEnabled() {
try {
workspaceFairnessEnabled =
(await SettingService.getGlobal({ key: WORKSPACE_FAIRNESS_ENABLED_SETTING })) === true
} catch (err) {
console.error('Failed to load the workspace fairness setting:', err)
}
}
$effect(() => {
;($superadmin || $devopsRole) && untrack(() => loadDefaultTagsPerWorkspace())
})
$effect(() => {
;($superadmin || $devopsRole) && untrack(() => loadWorkspaceFairnessEnabled())
})
$effect(() => {
groupedWorkers &&
selectedTab == 'default' &&
@@ -975,6 +989,7 @@
}}
activeWorkers={activeWorkers?.length ?? 0}
{defaultTagPerWorkspace}
{workspaceFairnessEnabled}
{width}
shouldAutoOpenDrawer={shouldAutoOpenDrawer === worker_group[0]}
onDrawerOpened={() => {
@@ -1360,6 +1375,7 @@
name={worker_group[0]}
config={worker_group[1]}
activeWorkers={0}
{workspaceFairnessEnabled}
{width}
shouldAutoOpenDrawer={shouldAutoOpenDrawer === worker_group[0]}
onDrawerOpened={() => {