You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test/test.sh reported ~18 false failures: assertion blocks returned empty strings, so checks compared '' against expected values and failed.
Root cause
obsidian-cli eval only returns a value if its async IIFE settles within the same microtask flush. Any setTimeout — confirmed empty down to 50ms — yields to the event loop and the eval times out to empty. Microtask-only async and blob-URL fetch reads resolve fine inside one eval, which is why the fast blocks already passed.
Fix
The six slow blocks (THEME_RERENDER, DEDUPED_NAVIGATION, DEFERRED_STATE_NAVIGATION, MARKDOWN_EMBED, SIZED_MARKDOWN_EMBED, CANVAS_EMBED) are restructured to trigger-eval → bash sleep → read-eval. State that must survive the wait (theme classes; the deferred-leaf getViewState monkey-patch + its original) is stashed on window. No assertion intent or expected value changed.
cleanup() had the same latent bug — its in-eval 300ms setTimeout returned empty, silently skipping the leftover-leaf verification. Split into detach → bash sleep → inspect/restore so cleanup verifies again.
Header comment updated npm test → bun run test. CI workflows untouched.
Validation
bun run test against the live vault, stable across two consecutive runs:
Adversarial review — Round 1 (Claude + Codex), head 1e2e313
Claude reviewer: VERDICT MERGEABLE. Two LOW advisory notes (no fix required): cleanup() dropped detachErrors from its JSON; deferred monkey-patch window slightly wider. Codex reviewer: VERDICT NOT MERGEABLE, 3 findings — all accepted and fixed in 6205ff1.
Resolutions
[HIGH] MARKDOWN_EMBED read eval re-found the wrong leaf (test/test.sh:418). DEDUPED_NAVIGATION and DEFERRED_STATE_NAVIGATION already open _html-docs-test-embed.md in earlier leaves, so re-finding 'first leaf by path' could read a non-preview leaf → false failure. Fixed (6205ff1): trigger eval stashes the exact opened leaf on window.__hvMarkdownEmbedLeaf; read eval reads that leaf and deletes the stash. (SIZED uses a unique note, CANVAS a unique file — unaffected.)
[MED] Deferred getViewState monkey-patch could leak (test/test.sh:350). The original try/finally restore now spans a bash boundary; a throw before the restore eval would leave the live leaf patched. Fixed (6205ff1): cleanup() (the trap EXIT path) defensively restores getViewState from window.__hvDeferredState if present.
[MED] Theme classes could be left flipped (test/test.sh:253). Same split-finally issue — a throw mid-flow would leave Obsidian's theme toggled. Fixed (6205ff1): cleanup() defensively restores the original theme classes from window.__hvThemeState if present.
Pushback
Claude's detachErrors note: keeping as-is. No assertion ever consumed detachErrors; a leaf that fails to detach still surfaces via the remaining array → exit 1. Net diagnostic loss is a less-specific message, not a missed failure.
Validation at new head
bun run test against the live vault: all outer + embed assertions pass, inner (iframe) 18 passed · 0 failed · 0 skipped, exit 0.
Adversarial review — Round 2 (confirm), head 6205ff1
Consensus reached. Fresh reviewers from both families re-read the full diff and verified all three round-1 resolutions:
Claude: all 3 CONFIRMED RESOLVED, no new issues — VERDICT MERGEABLE
Codex: all 3 CONFIRMED RESOLVED, no new issues — VERDICT MERGEABLE
Both confirmed: MARKDOWN_EMBED now reads the exact stashed leaf (no path re-find); cleanup() restores the deferred getViewState patch and theme classes on the guaranteed trap EXIT path, before detach, and is idempotent with the success path (no double-restore). No in-eval setTimeout remains; bash -n clean.
Flipping out of draft and assigning @smcllns. Not merging — Sam merges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17
Problem
test/test.shreported ~18 false failures: assertion blocks returned empty strings, so checks compared''against expected values and failed.Root cause
obsidian-cli evalonly returns a value if its async IIFE settles within the same microtask flush. AnysetTimeout— confirmed empty down to 50ms — yields to the event loop and the eval times out to empty. Microtask-only async and blob-URLfetchreads resolve fine inside one eval, which is why the fast blocks already passed.Fix
The six slow blocks (THEME_RERENDER, DEDUPED_NAVIGATION, DEFERRED_STATE_NAVIGATION, MARKDOWN_EMBED, SIZED_MARKDOWN_EMBED, CANVAS_EMBED) are restructured to trigger-eval → bash
sleep→ read-eval. State that must survive the wait (theme classes; the deferred-leafgetViewStatemonkey-patch + its original) is stashed onwindow. No assertion intent or expected value changed.cleanup()had the same latent bug — its in-eval 300mssetTimeoutreturned empty, silently skipping the leftover-leaf verification. Split into detach → bash sleep → inspect/restore so cleanup verifies again.Header comment updated
npm test→bun run test. CI workflows untouched.Validation
bun run testagainst the live vault, stable across two consecutive runs: