#1824·visdom

[Bug Report] Filtered 'Select All' in EnvModal discards selections from other filters

Author: Pcmhacker-piroCreated Sep 13, 2026Updated Sep 13, 2026

Bug Description In the environment management modal (EnvModal.js), when environments are filtered using the search input, checking or unchecking the "Select All" checkbox overwrites or wipes all selections across the modal rather than scoping the operation to the visible filtered environments.

Specifically, in js/modals/EnvModal.js:

javascript
<input
  type="checkbox"
  style={{ marginRight: '8px' }}
  disabled={!canWrite || selectableEnvs.length === 0}
  checked={isAllSelected}
  onChange={(ev) => {
    setSelectedEnvs(ev.target.checked ? selectableEnvs : []);
  }}
/>
  1. When checking "Select All" with a filter active, setSelectedEnvs(selectableEnvs) directly overwrites selectedEnvs with only the filtered items, silently discarding any environments previously selected under other search filters.
  2. When unchecking "Select All" with a filter active, setSelectedEnvs([]) clears the entire selection across all environments in the modal, rather than deselecting only the visible filtered environments.

Individual environment checkboxes correctly preserve other selections via functional updates:

javascript
onChange={(ev) => {
  if (ev.target.checked) {
    setSelectedEnvs((prev) => Array.from(new Set([...prev, env])));
  } else {
    setSelectedEnvs((prev) => prev.filter((e) => e !== env));
  }
}}

However, the "Select All" checkbox does not use the existing selections and resets the state completely.

Reproduction Steps

  1. Launch Visdom with multiple environments (e.g., model_a_1, model_a_2, model_b_1, model_b_2).
  2. Open the "Manage Environments" modal.
  3. In "Filter environments...", type model_a.
  4. Select model_a_1 (or click "Select All" to select all model_a environments).
  5. In "Filter environments...", change the search term to model_b.
  6. Click "Select All" to include the model_b environments for batch deletion.
  7. Observe that model_a_1 has been discarded from selectedEnvs; only model_b environments are now selected.
  8. Alternatively, with model_a_1 selected and model_b filtered with "Select All" checked, uncheck "Select All". Notice all selections across all environments are cleared to [].

Expected behavior

  • Checking "Select All" with a filter applied should add the visible selectable environments to the existing selection (union): setSelectedEnvs((prev) => Array.from(new Set([...prev, ...selectableEnvs])))
  • Unchecking "Select All" with a filter applied should only remove the visible selectable environments from the existing selection: setSelectedEnvs((prev) => prev.filter((env) => !selectableSet.has(env)))

Client logs: No errors are thrown in the console, but the state selectedEnvs is incorrectly overwritten/cleared.

Server logs: N/A (Frontend state management issue).

Additional context Environment filtering and batch deletion were introduced in #1791. The intention was to allow users to efficiently filter and delete runs matching naming patterns in batches; however, the inability to combine or refine selections across successive filter queries hinders batch operations.