Skip to content

fix: admin remove-by-limit input no longer deletes runs on click (#333) - #335

Open
timdegroot1996 wants to merge 2 commits into
mainfrom
fix/333-admin-remove-limit-click
Open

timdegroot1996 wants to merge 2 commits into
mainfrom
fix/333-admin-remove-limit-click

Conversation

@timdegroot1996

Copy link
Copy Markdown
Collaborator

Fixes #333

Problem

On the admin page, clicking the "outputs to remove by limit" number input (including its spinner arrows) immediately sent a DELETE /remove-outputs request, without pressing Remove and without confirmation. A down-arrow click on an empty field sent limit=-1, which removed every run in the database.

Root cause

  • admin_eventlisteners.js attached the remove_outputs click handler to the #removeLimit input as well as the #removeOutputs button (since Removeruns by limit and vacuum database #188).
  • _remove_by_limit only guarded limit >= len(candidates); a negative limit made the removal slice candidates[: len - limit] cover the whole list.

Fix

  • Only the Remove button triggers remove_outputs.
  • remove_outputs now asks for confirmation (same modal as Remove All), refuses an empty form, and rejects a limit below 1 client-side before clearing the fields.
  • #removeLimit has min="1".
  • RemoveOutputs.limit is Field(ge=1) → the API answers 422 for limit < 1.
  • _remove_by_limit rejects limit < 1 with an error, so the CLI -r limit=0 / limit=-1 no longer wipes the database either.
  • Docs note the lower bound.

Tests

  • test_remove_by_limit_below_one_is_rejected (database): limit=0 / limit=-1 remove nothing and report an error.
  • test_remove_outputs_by_limit_below_one_is_rejected (server): limit=0 / limit=-1 → 422, remove_outputs never called.
  • Both fail without the fix; Python suite 392 passed, JS suite 266 passed.
  • Manually verified against a server run from source: admin bundle has no #removeLimit listener, min="1" present, negative limit → 422.

🤖 Generated with Claude Code

The "outputs to remove by limit" number input on the admin page had the
same click listener as the Remove button, so clicking the input's
spinner arrows immediately sent a DELETE /remove-outputs request with
whatever value the click produced. A down-arrow click on an empty field
sent limit=-1, which slipped past the "limit >= number of runs" guard in
_remove_by_limit and, through the negative slice, removed every run in
the database. No confirmation was asked.

- Only the Remove button triggers remove_outputs now.
- remove_outputs asks for confirmation (same modal as Remove All),
  refuses an empty form and a limit below 1 before clearing the fields.
- The input carries min="1".
- The server model rejects limit < 1 with a 422.
- _remove_by_limit rejects limit < 1 with an error, so the CLI
  -r limit=0 / limit=-1 no longer wipes the database either.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant