authorgravatar for lucenz@proton.meSimone <lucenz@proton.me> 2026-09-17 12:47:53+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-17 16:17:53+05:30
log1ab2dfb5a7bd2996f79407b5d02cae6132a7626c
tree731c3bd9ecba12d6414a1e40ae33676aed719172
parent298f8c95cd7c20ea7943a431f22e836fa637457b
signature Signed by PGP key B5690EEEBB952194

fix(desktop): keep preview picking active across subframe navigation (#9741)

Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com> Co-authored-by: shivam <91240327+shivamhwp@users.noreply.github.com>

2 files changed, 21 insertions(+), 9 deletions(-)

apps/desktop/src/preview/Manager.test.ts+18-3
......@@ -3506,7 +3506,10 @@ describe("PreviewManager", () => {
35063506 listeners.set(event, listener);
35073507 }),
35083508 once: vi.fn((event: string, listener: (...args: unknown[]) => void) => {
3509 listeners.set(event, listener);
3509 listeners.set(event, (...args) => {
3510 listeners.delete(event);
3511 listener(...args);
3512 });
35103513 }),
35113514 off: vi.fn(),
35123515 ipc: { on: vi.fn(), off: vi.fn(), removeListener: vi.fn() },
......@@ -3528,11 +3531,23 @@ describe("PreviewManager", () => {
35283531 const pick = yield* manager.pickElement("tab_1").pipe(Effect.forkChild);
35293532 yield* Effect.yieldNow;
35303533
3531 listeners.get("did-start-navigation")?.({}, "about:blank", false, false);
3534 listeners.get("did-start-navigation")?.({
3535 url: "about:blank",
3536 isSameDocument: false,
3537 isMainFrame: false,
3538 frame: null,
3539 });
35323540 yield* Effect.yieldNow;
35333541 expect(pick.pollUnsafe()).toBeUndefined();
35343542
3535 listeners.get("did-start-navigation")?.({}, "https://example.com/next", false, true);
3543 listeners.get("did-start-navigation")?.({
3544 url: "https://example.com/next",
3545 isSameDocument: false,
3546 isMainFrame: true,
3547 frame: null,
3548 });
3549 yield* Effect.yieldNow;
3550 expect(pick.pollUnsafe()).toBeDefined();
35363551 expect(yield* Fiber.join(pick)).toBeNull();
35373552 }),
35383553 ),
apps/desktop/src/preview/Manager.ts+3-6
......@@ -2566,12 +2566,9 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
25662566 };
25672567 const onDestroyed = () => settle(null);
25682568 const onNavigated = (
2569 _event: Electron.Event,
2570 _url: string,
2571 _isInPlace: boolean,
2572 isMainFrame: boolean,
2569 event: Electron.Event<Electron.WebContentsDidStartNavigationEventParams>,
25732570 ) => {
2574 if (isMainFrame) settle(null);
2571 if (event.isMainFrame) settle(null);
25752572 };
25762573 const registerPickElement = Effect.fn("PreviewManager.registerPickElement")(function* () {
25772574 // Two picks on one tab can overlap. Swap this session in and cancel
......@@ -2592,7 +2589,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
25922589 yield* attempt({ operation: "pickElement.register", tabId, webContentsId: wc.id }, () => {
25932590 wc.ipc.on(ELEMENT_PICKED_CHANNEL, onMessage);
25942591 wc.once("destroyed", onDestroyed);
2595 wc.once("did-start-navigation", onNavigated);
2592 wc.on("did-start-navigation", onNavigated);
25962593 if (!wc.isFocused()) wc.focus();
25972594 wc.send(START_PICK_CHANNEL, annotationTheme);
25982595 });