Preheat oven to 350 degrees. Lay each piece of foil flat, and spoon 1/4 of each of the first six ingredients (the butter, brown sugar if desired, shallots, garlic, rosemary and thyme) onto the center of each piece.
For each onion: cut off the shriveled end, then cut 6-8 shallow slits just through the brown peel, going lengthwise all the way from the shriveled end to the root; pull back the flaps of peel in a bunch, like a pony tail, over the root; plop the onion on top of the pile of seasonings on the foil, and then bunch the foil all around it, so the whole onion is completely wrapped -- except for the bunched up onion peel, which should be poking out the top.
Pour 1/4 of the sherry vinegar and stock, plus a few pinches of salt and pepper, into each of the foil packets before giving the foil a final pinch to seal it well, and bake on a cooking sheet for around 45 minutes or until soft. (Note: the onion peel will be black.).
When the onion is done, heat a Tbsp or so of butter or olive oil in a saute pan over medium high-high heat, add the mushroom chunks and ham and saute until slightly browned, stir in the diced tomato, pour in the juices from the onion packets, stir until hot and then remove from heat. Salt and pepper to taste, add a bit more sherry vinegar if desired, and then whisk in additional salad oil (if desired) to make it into a vinaigrette.
Put each onion in the center of a plate and spoon sauce around it, sprinkle with chives.