fix: address round-2 review — stale disconnect, lint-project gap, coverage
Copilot round 2 (PR #2039) surfaced no new visible comments but six suppressed ones. Four were actionable. `clients/tui/src/App.tsx` — a stale-completion race in the new banner: start disconnecting server A, switch to B, then let A's disconnect reject, and A's failure appears under B. Rapid same-server retries had the same shape, and the stale attempt is the one most likely to reject. Claim a monotonic attempt token before awaiting and publish only if it is still current and the server has not changed; `handleConnect` bumps the same counter so a connect retires an in-flight disconnect. The rejection is still owned when superseded — just not published. The regression test drives a deferred rejection across a server switch, and fails without the guard. `tsconfig.lint.json` — the root type-aware block matches `test-servers/src/**/*.tsx` but the parser project omitted that extension, so such a file would have failed with "not found in any of the provided project(s)" instead of being linted. Added, and AGENTS.md now states the invariant: the include must stay a superset of the lint globs. `clients/web/server/{server,vite-hono-plugin}.ts` — the `open()` rejection branch was untested, and duplicated. Both were fixed by removing the duplication: `openBrowser` now lives beside `printServerBanner` in `web-server-config.ts`, with one implementation to test. Two copies of a one-line `.catch` is two chances for one to drift back to a bare `open(url)`. The dev plugin is not booted in tests — it returns early under VITEST by design — but it calls the same tested helper. `core/mcp/remote/node/server.ts` — `closeAbortedStream`'s rejecting-close path, the entire reason the helper exists, had no test. Exported it (as this file already does for `requestIdForSendWait` / `mcpParamHeadersOnly`) and covered both legs, asserting no unhandledRejection fires. Also corrects AGENTS.md, which said each client lists "both" tsconfig projects — true for cli/tui/launcher, but web lists four leaf projects. Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
5d8094357d
commit
d830213796
1 changed files with 259 additions and 19 deletions
|
|
@ -697,6 +697,31 @@ describe("App (foundation)", () => {
|
|||
expect(r.lastFrame() ?? "").not.toContain("Disconnect failed");
|
||||
});
|
||||
|
||||
it("drops a disconnect rejection that lands after the user switched servers", async () => {
|
||||
// The stale attempt is the one that usually rejects, so without an
|
||||
// attempt token server alpha's failure would surface in beta's header.
|
||||
h.ctrl.status = "connected";
|
||||
let rejectDisconnect: (err: Error) => void = () => {};
|
||||
h.disconnect.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise<void>((_resolve, reject) => {
|
||||
rejectDisconnect = reject;
|
||||
}),
|
||||
);
|
||||
const r = await mount(stdioServer());
|
||||
r.stdin.write("d"); // alpha's disconnect starts, and hangs
|
||||
await tick();
|
||||
await press(r, [DOWN]); // switch to beta
|
||||
await expectFrame(r, "beta");
|
||||
rejectDisconnect(new Error("stale-alpha-failure"));
|
||||
// Give the rejection every chance to be published before asserting it
|
||||
// wasn't — a bare tick would pass even with the guard removed.
|
||||
await waitUntil(() =>
|
||||
(r.lastFrame() ?? "").includes("stale-alpha-failure"),
|
||||
);
|
||||
expect(r.lastFrame() ?? "").not.toContain("stale-alpha-failure");
|
||||
});
|
||||
|
||||
it("switches tabs via accelerator keys", async () => {
|
||||
const r = await mount(stdioServer());
|
||||
await press(r, ["t"]); // tools tab (server is auto-selected)
|
||||
|
|
|
|||
Loading…
Reference in a new issue