From 98ce29e5fabef05abae308475c9fcd5ac63a7aaf Mon Sep 17 00:00:00 2001 From: Jack Williams Date: Mon, 23 Mar 2026 22:31:16 +1100 Subject: [PATCH] Preload note IDs to improve matchmaking --- src/ui/ArenaSession.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ui/ArenaSession.ts b/src/ui/ArenaSession.ts index 4937816..1728fca 100644 --- a/src/ui/ArenaSession.ts +++ b/src/ui/ArenaSession.ts @@ -117,12 +117,28 @@ export default class ArenaSession { this.plugin.registerDomEvent(win, 'beforeunload', this.popoutUnloadHandler); } + await this.preloadFileIds(); this.pickNextPair(); await this.openCurrent(); this.updateOverlay(); this.updateStabilityBar(); } + /** + * Read note IDs for all files up-front so the matchmaker can look up + * actual stats on the first pair pick, allowing the information-gain + * algorithm to prioritise genuinely new notes. + */ + private async preloadFileIds(): Promise { + const propName = this.plugin.settings.idPropertyName; + await Promise.all( + this.files.map(async (f) => { + const id = await getNoteId(this.app, f, propName); + if (id) this.idByPath.set(f.path, id); + }), + ); + } + async end(opts?: { forUnload?: boolean }) { this.clearScrollSync();