Skip to content

thv: Stop on a Foreground Process Removes the Workload #2950

@jerm-dro

Description

@jerm-dro

Bug description

Running thv stop on a workload started by thv run --foreground causes the workload to be removed from thv list --all results.

This is perceived as a bug, because stop is effectively acting as rm.

Steps to reproduce

  1. thv run --foreground --name fetch-foreground fetch
  2. In another shell: thv stop fetch-foreground
  3. Observe thv list --all does not contain fetch-foreground

Expected behavior

There are multiple acceptable behaviors:

  • thv stop cannot be run on foreground workloads
  • thv stop does not remove the state for the foreground workload, but stops it. In other words, thv list --all contains fetch-foreground and it is in a stopped status.

Actual behavior

thv stop behaves like thv rm when executed against foreground workloads.

Environment (if relevant)

  • OS/version: Mac Version 15.4.1
  • ToolHive version: v0.6.11-42-g2b6a4a76

Additional context

This PR contains significant prior art: #2927 (review)

The problem is the --foreground process acts as the owner of the workload and will always remove the workload when it exits. This can be seen in the logs below:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliChanges that impact CLI functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions