Skip to content

Commit 6a7c30a

Browse files
nodeeeeeeclaude
andcommitted
Show actual Python script output when smart match fails or succeeds
Instead of generic "possible causes", the terminal now shows the exact output from the Python script: - On empty results: full script log (shows which step failed and why) - On success: script log shown below the match results - On error: raw error output shown directly The __log field is attached to the JSON result so the renderer always has access to the script's diagnostic output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ec26da9 commit 6a7c30a

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

electron/main.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,14 +1070,16 @@ function registerIpc() {
10701070
const marker = '__MATCH_RESULT__';
10711071
const idx = combined.indexOf(marker);
10721072
if (idx < 0) {
1073-
console.error(`[align:suggestMatches] no marker:\n${combined.slice(-500)}`);
1074-
resolve({ __error: `No match results. Log: ${combined.slice(-300)}` });
1073+
resolve({ __error: combined.trim() || 'Script produced no output.' });
10751074
return;
10761075
}
10771076
try {
1078-
resolve(JSON.parse(combined.slice(idx + marker.length).trim()));
1077+
const result = JSON.parse(combined.slice(idx + marker.length).trim());
1078+
// Attach the log so the UI can show it even on empty results
1079+
result.__log = combined.slice(0, idx).trim();
1080+
resolve(result);
10791081
} catch (e) {
1080-
resolve({ __error: `JSON parse error: ${e.message}` });
1082+
resolve({ __error: `JSON parse error: ${e.message}\n\n${combined.trim()}` });
10811083
}
10821084
});
10831085
});

electron/renderer/app.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,26 +1510,26 @@ async function attachPageHandlers() {
15101510
return;
15111511
}
15121512

1513-
if (!matches || !Object.keys(matches).length) {
1514-
Term.write('\n✗ Smart match returned empty results.\n'
1515-
+ 'Possible causes:\n'
1516-
+ ' - pymupdf not installed (cannot read PDF slide text)\n'
1517-
+ ' - sentence-transformers not installed (cannot embed text)\n'
1518-
+ ' - No captions or materials found for this course\n'
1519-
+ ` - Course dir: check if files exist under Output Dir / ${cid}\n`, 'warn');
1520-
snack('No embedding matches — see terminal for diagnostics.', false);
1521-
if (statusEl) statusEl.textContent = 'No matches — check terminal.';
1513+
// Filter out internal keys
1514+
const log = matches?.__log || '';
1515+
const matchKeys = Object.keys(matches).filter(k => !k.startsWith('__'));
1516+
1517+
if (!matchKeys.length) {
1518+
Term.write(`\n✗ Smart match returned no results.\n\n── Script output ──\n${log || '(empty)'}\n`, 'warn');
1519+
snack('No embedding matches — see terminal for details.', false);
1520+
if (statusEl) statusEl.textContent = 'No matches — see terminal.';
15221521
return;
15231522
}
15241523

15251524
// Apply embedding suggestions to rows
15261525
let updated = 0;
15271526
for (const row of AlignState.rows) {
1528-
if (matches[row.stem]) {
1527+
if (matches[row.stem] && !row.stem.startsWith('__')) {
15291528
row.slides = [matches[row.stem]];
15301529
updated++;
15311530
}
15321531
}
1532+
if (log) Term.write(`\n── Smart match log ──\n${log}\n`, 'cmd');
15331533
_alignRebuildRows();
15341534
snack(`Smart match: ${updated}/${AlignState.rows.length} video(s) matched via ${model}.`);
15351535
});

0 commit comments

Comments
 (0)