Skip to content

fix(hunts): show and set a hunt's enabled state - #744

Open
catinspace-au wants to merge 3 commits into
mainfrom
fix/hunt-disable
Open

catinspace-au wants to merge 3 commits into
mainfrom
fix/hunt-disable

Conversation

@catinspace-au

Copy link
Copy Markdown
Contributor

Pairs with hyperi-io/dfe-engine#1191 (hunt enable, disable and auto-disable, dfe-engine#1179), for 2.2.3.

The hunt list row and detail header have a state tag. Disabled means the YAML turns the hunt off. Auto-disabled means the runner stopped the hunt after repeated ClickHouse resource-limit failures. The tooltip gives the time and reason. It says Re-enable clears the stop.

The actions menu has Disable, Enable or Re-enable. A toggle fetches the latest hunt config and writes it with the changed flag. This preserves edits made since the page loaded.

The edit form has an Enabled switch. A runner stop is shown above it. Leaving the switch alone sends no enabled. The engine treats that as unchanged, preserving a runner stop.

The stop is read from the hunt detail, falling back to the list row. Direct links outside the loaded page still show the stop. The engine spec and client types come from #1191.

Test setup on desktop-derek: the #1191 engine's e2e server, a hunt runner and this console.

e2e/specs/huntEnabled.spec.ts has three cases:

  • Disable and Enable from the menu.
  • An edit that omits enabled keeps a disabled hunt disabled.
  • A runner-stopped hunt shows Auto-disabled until Re-enable.

The third case covers a runner stop of a YAML hunt on code 158. It needs E2E_STOPPED_HUNT and a runner against the engine.

Vitest: 138 across the Hunts tree. check-types and lint: clean. The spec writes screenshots of the four states to test-results/hunt-enabled when it runs.

The Hunts console had no way to see or change whether the runner fires a hunt.

- The list row and detail header show Disabled or Auto-disabled. The tooltip shows the stop time and ClickHouse reason.
- The detail action menu has Disable, Enable and Re-enable. Each sends a PUT with enabled.
- The hunt form has an Enabled switch. Edits send enabled only when the switch changes. Any PUT with enabled true clears a runner stop.
- The update request type makes enabled optional. The generated type needs enabled for its default.
- Regenerated engine types match the spec and have the engine's other changes.
The engine returns auto_disabled_at and auto_disabled_reason on GET /hunts/{name}. The console read the stop from the loaded list page. A direct link to a hunt outside that page showed no Auto-disabled tag and offered Disable instead of Re-enable.

- useHuntRunState takes the stop from the detail and falls back to the list row only for an engine that leaves the field out.
- Enable, Disable and Re-enable fetch the hunt before the PUT. The engine has no per-field write, so a toggle sends the whole config. Without the read, it could undo an edit made since the page loaded.
- Above the Enabled switch, the edit drawer warns when the runner stopped the hunt. It says a save leaves the hunt stopped.
- Engine types regenerated from the engine's spec. A Playwright spec covers the toggle and the edit rule against the live stack.
The actions menu fetched the hunt afresh for the PUT body but took the toggle direction from page state. If another session changed enabled after page load, the button wrote the opposite enabled value.

- After the read, a hunt with auto_disabled_at set gets enabled true, and any other hunt gets the opposite of its enabled value.
- The success and failure notices name the direction that was sent.
- The menu label still comes from the page state, because it only guides the click.
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