chore(web): address Copilot review on #2128

Seven of the eight comments, plus the three suppressed ones (the same
double-cast class):

- Narrow the toast hooks to `InspectorClientEventSource`, the client's
  typed event-listener surface. A bare `EventTarget` cannot satisfy it
  (its listener takes an `Event`, the typed one a `TypedEventGeneric`
  with `detail`), so both tests now construct a real
  `InspectorClientEventTarget` and dispatch through `dispatchTypedEvent`
  rather than casting a stand-in. That failed to compile immediately and
  caught two bad fixtures: `task()` was a `Pick<Task, "status">` where
  the event map wants a full `Task`, and `toolCallTaskUpdated` was
  dispatched with no `task` at all.
- Narrow `useExportActions`'s three store parameters to the single
  clearing method each handler calls, so the test doubles are
  structurally checked instead of cast away.
- Build real `MessageEntry` fixtures (`timestamp` is a `Date`, not `0`),
  removing four more double casts.
- Fix a tautological assertion in useTabUiState.test: it compared a
  callback to itself, so it held however the identity changed. Every
  callback is now captured before the update and compared to those
  references.
- Reword `resetTabUiState`'s doc: `exhaustive-deps` cannot infer
  stability across a hook boundary, so the dependency IS named — the
  stability buys no churn, not omission.
- Justify the one remaining double cast in place, per the type-safety
  rule.

`useProgressToasts` still returns `void` rather than an object,
deliberately: it has nothing to return, and `{}` would imply an API that
is not there. Noted on the PR as the one deviation from #2128's
"returns one object" criterion.

Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-08-26 19:58:02 -04:00
commit edac58e304

View file

@ -127,7 +127,16 @@ vi.mock("@inspector/core/react/useStderrLog.js", () => ({
useStderrLog: () => ({ stderrLogs: [{ id: "s1" }] }),
}));
const client = () => ({ id: "client" }) as unknown as InspectorClient;
/**
* A per-call identity token standing in for the client. Every store
* constructor is mocked away below, so nothing here ever reads a property off
* it — the assertions only check *which* value each constructor received, and
* that a second `createStores` passes a different one. The double cast is what
* that isolation buys: building a real `InspectorClient` would drag in a
* transport and an environment to assert on object identity.
*/
const client = () =>
({ marker: Symbol("client") }) as unknown as InspectorClient;
const fetchLogOptions = {
maxFetchRequests: 42,