fix(diagnostics): deep-review round 3 — a keyboard owner that is not a Tab trap
Round 2 made the step prompt a blocking layer so that `j` and the `g` chords would not reach the page behind it. The dialog it sits in gave up its Tab trap because of that, while the prompt's own replacement trap covered only its own two controls — so Tab from anywhere else in the dialog (the bar's Screenshot or Stop, the dialog's own buttons) walked out behind the scrim. `layerStack` now separates the two questions it had folded into one flag: a layer can own the keyboard and still leave the Tab trap to the dialog below it. The mirror case, a dialog opening over the prompt, falls out of the same split. A send's claim is now a lease with an owner. Every progress report re-stamps it, so a send slower than the lease cannot lose it while it is still running, and only the send that took a claim can give it back. The issue_create audit row is staged inside the send and rides the same checkpoint as `issue_url`, so the trail cannot be missing for an issue that exists. The attachment-name prefix has one definition, shared by the producer and both readers. A running send is reported to the UI. A reload or a second tab used to render it exactly like a send that STOPPED, and offered a retry the server was certain to refuse; the composer now says the report is being sent, holds the draft, and puts both the retry and Create issue out. The past-sessions list says the same for the same reason — it is the list a user opens to check on a send, and both "draft" and "half sent" describe one that died. `/preview` and the retry path got a pace of their own, and the per-user byte cap took the user-scoped lock that makes it a cap instead of a guess. Verified in a real browser on localdev: Tab cycles the whole dialog with the prompt open, the prompt still swallows the page's keys, and the issue link is focusable where the composer puts it. All 24 regression tests mutation-checked.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// @vitest-environment jsdom
|
||||
//
|
||||
// The zip export is the one api method that reads a RAW response instead of a parsed answer, so it
|
||||
// carries contract of its own: the bytes, and the name the server picked. The composer's DOM test
|
||||
// mocks this method wholesale, so without this the blob and the filename parse ship untested — and
|
||||
// a broken header regex would silently save every report under the fallback name.
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
|
||||
vi.mock("../errorDialog", () => ({ reportError: vi.fn() }));
|
||||
vi.mock("../notifications", () => ({
|
||||
notify: vi.fn(() => 1),
|
||||
remove: vi.fn(),
|
||||
getActiveToasts: vi.fn((): { id: number }[] => []),
|
||||
}));
|
||||
vi.mock("../../i18n", () => ({ default: { t: (k: string) => k, language: "en" } }));
|
||||
vi.mock("../activeAccount", () => ({
|
||||
activeAccountId: () => null,
|
||||
ACTIVE_ACCOUNT_KEY: "k",
|
||||
pinActiveAccount: () => {},
|
||||
}));
|
||||
|
||||
import { debugSessionsApi } from "./diagnostics";
|
||||
|
||||
const zip = (disposition?: string) =>
|
||||
new Response("PK", {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/zip",
|
||||
...(disposition ? { "content-disposition": disposition } : {}),
|
||||
},
|
||||
});
|
||||
|
||||
beforeEach(() => vi.restoreAllMocks());
|
||||
|
||||
describe("debugExport", () => {
|
||||
it("hands back the bytes and the name the server chose", async () => {
|
||||
vi.spyOn(globalThis, "fetch").mockResolvedValue(
|
||||
zip('attachment; filename="siftlode-debug-20260919-1402-abc123.zip"'),
|
||||
);
|
||||
|
||||
const out = await debugSessionsApi.debugExport("0123456789abcdef");
|
||||
|
||||
expect(out.name).toBe("siftlode-debug-20260919-1402-abc123.zip");
|
||||
// The body is read as bytes, not parsed: `r.json()` on a zip would throw on its first one.
|
||||
expect(out.blob).toBeInstanceOf(Blob);
|
||||
expect(out.blob.size).toBe(4);
|
||||
});
|
||||
|
||||
it("names the file itself when the answer does not", async () => {
|
||||
// A proxy that strips the header must not leave the browser saving something called "export".
|
||||
vi.spyOn(globalThis, "fetch").mockResolvedValue(zip());
|
||||
|
||||
const out = await debugSessionsApi.debugExport("0123456789abcdef");
|
||||
|
||||
expect(out.name).toBe("siftlode-debug-0123456789abcdef.zip");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user