fix(llm): the document viewer ends its non-PDF paths by returning from one async flow instead of sentinel throws that surfaced as page errors
Some checks failed
CI / lint (push) Successful in 34s
CI / notebooks-smoke (push) Successful in 1m41s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
CI / test (push) Failing after 2m25s
Deploy / docs (push) Has been skipped
Deploy / api (push) Has been skipped
Deploy / llm (push) Has been skipped
Deploy / mc (push) Has been skipped
Infra CI / zotero (push) Successful in 14s
Infra CI / docs (push) Successful in 20s
Infra CI / notebooks (push) Successful in 49s
Infra CI / llm (push) Successful in 47s
Infra CI / api (push) Successful in 1m6s
Deploy / report (push) Successful in 12s
Infra CI / mc (push) Failing after 36s

This commit is contained in:
kert
2026-09-24 19:06:51 -04:00
parent 6324960f28
commit 068963e8ca

View File

@@ -186,6 +186,7 @@
pdfjs = null;
}
async function show() {
// ── file list ──
let files = [];
try {
@@ -211,11 +212,7 @@
}
if (files.length > 1) sel.hidden = false;
const current = files.find(f => f.name === wantFile) || files.find(f => f.renderable) || files[0];
// the "done:" throws below end this module on purpose once a non-PDF
// pane is up; keep the console quiet about them
window.addEventListener('unhandledrejection', ev => {
if (ev.reason && /^done: /.test(String(ev.reason.message || ev.reason))) ev.preventDefault();
});
sel.value = current.name;
const fileUrl = '/pdf/' + encodeURIComponent(key) + '/file?name=' + encodeURIComponent(current.name);
$('download').href = fileUrl;
@@ -351,7 +348,7 @@
const find = domFind(pre);
nav.goTo(1, false);
seedFind(find);
throw new Error('done: text'); // the module's PDF path below must not run
return;
}
// ── Word (.docx) via docx-preview: sections become pages; zoom scales
@@ -414,7 +411,7 @@
const hashPage = parseInt((location.hash.match(/page=(\d+)/) || [])[1] || '0', 10);
nav.goTo(hashPage || wantPage, false);
seedFind(find);
throw new Error('done: docx'); // stop before the PDF path
return;
}
if (!pdfjs) {
@@ -666,6 +663,8 @@
$('find').value = probe;
runFind(probe);
}
}
show().catch(e => console.warn('viewer:', e && e.message || e));
</script>
</body>
</html>