fix: collection first-run pending and module tab cross-nav

Defer collection scheduling to BackgroundTasks after commit; claim pending runs atomically with retries. Only handle focus-module broadcasts for the matching moduleId so opening one module does not rewrite other tabs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-28 10:22:11 +08:00
parent 3413d5bf32
commit fed7f56ad0
5 changed files with 169 additions and 43 deletions

View file

@ -36,13 +36,18 @@ export function registerModuleWindow(moduleId: string): () => void {
/* ignore */
}
return registerBroadcastListener<FocusModuleMessage>(MODULE_CHANNEL, moduleAckKey(moduleId), (data) => {
const targetPath = String(data.path || "").trim();
if (targetPath && window.location.pathname !== targetPath) {
window.location.assign(targetPath);
}
window.focus();
});
return registerBroadcastListener<FocusModuleMessage>(
MODULE_CHANNEL,
moduleAckKey(moduleId),
(data) => {
const targetPath = String(data.path || "").trim();
if (targetPath && window.location.pathname !== targetPath) {
window.location.assign(targetPath);
}
window.focus();
},
(data) => data.moduleId === moduleId,
);
}
export function openOrFocusModule({ moduleId, path }: ModuleWindowSpec): void {