WebView can retain document focus after another Windows application becomes foreground. Project each Piik window's actual activation into its document and share that fact across message feedback, read markers, shortcut ownership and remote-input reset. Keep media visibility and room grants independent. The same real foreground-window transition reproduces silence and premature read advancement on beta.53, then triggers cues and preserves unread position on the candidate. Returning to Piik advances the cursor. Audio output was muted in the experiment; oscillator execution and completion were measured. All 2315 Web tests, TypeScript and the Windows capture-enabled App check pass.
20 lines
826 B
TypeScript
20 lines
826 B
TypeScript
import { expect, test } from "vitest";
|
|
import { isDocumentActive } from "../src/client/ui/document-active";
|
|
|
|
function page(hidden: boolean, focused: boolean, piikNativeActive?: boolean): Document {
|
|
return { hidden, hasFocus: () => focused, defaultView: { piikNativeActive } } as Document;
|
|
}
|
|
|
|
test("ordinary browser activity follows visibility and focus", () => {
|
|
expect(isDocumentActive(page(false, true))).toBe(true);
|
|
expect(isDocumentActive(page(true, true))).toBe(false);
|
|
expect(isDocumentActive(page(false, false))).toBe(false);
|
|
});
|
|
|
|
test("a foreground conversation popup and its inactive opener have independent activity", () => {
|
|
const opener = page(false, true, false);
|
|
const popup = page(false, true, true);
|
|
expect(isDocumentActive(opener)).toBe(false);
|
|
expect(isDocumentActive(popup)).toBe(true);
|
|
});
|