Skip to content

fix(navigation): open the correct chapter/verse when deep-linking into a not-yet-open book (#996)#1025

Open
sampjvv wants to merge 1 commit into
mainfrom
996-cold-open-chapter-nav
Open

fix(navigation): open the correct chapter/verse when deep-linking into a not-yet-open book (#996)#1025
sampjvv wants to merge 1 commit into
mainfrom
996-cold-open-chapter-nav

Conversation

@sampjvv
Copy link
Copy Markdown
Contributor

@sampjvv sampjvv commented Jun 3, 2026

What & why

Fixes #996"When clicking on cells without audio, the proper chapter doesn't open."

In the export wizard's Step 1 audio-stats popover (which lists a book's text-only cells), clicking a cell is supposed to open the source+target editors and navigate to that cell's chapter/verse. When the book was not already open, it instead opened at chapter 1 (e.g. clicking 11:20 → chapter 1). When the book was already open, it worked — which made it intermittent.

Root cause (cold-open race)

openCodexDocumentWithSourcePair opened the source pane and awaited waitForWebviewReady(source), then opened the target .codex pane without waiting for it. Callers (the export popover via jumpToCellInNotebook) publish the navigation jump — the cellToJumpTo workspace-state key — immediately after this helper returns.

The per-editor cellToJumpTo listener is registered while the editor resolves, and waitForWebviewReady only returns once a pane has signalled ready (i.e. after it resolved + registered its listener). With the target pane not waited for, a cold-opened editor could miss the jump and fall back to its default initial page (chapter 1). The general jump path was hardened for the search view back in March, but this helper's missing target-pane wait left the export deep-link (added shortly before this was reported) exposed.

Fix

Resolve the editor provider once and await waitForWebviewReady for both panes (source and target) before returning — in the normal path, the source-failed fallback, and the no-workspace path. Cold-open now behaves like the working warm-open.

The helper is shared (navigation sidebar, NewSourceUploader "Start translating"), so they get the same small target-readiness wait and the same cold-open race protection; no other behavior change.

Changes

  • src/utils/openCodexDocumentWithSourcePair.ts — wait for the target pane's webview ready (plus a single provider lookup + small waitForPaneReady helper).

Testing

  • npm run compile clean; typecheck clean for the changed file.
  • Manual (the confirmed repro): reload the Extension Dev Host → close all editor tabs → export wizard → click a chapter-2+ text-only cell (e.g. 11:20) → opens both panes at the correct chapter/verse, not chapter 1.
  • Regression: warm open (book already open) still correct; navigation-sidebar verse open and "Start translating" still open the pair correctly.

🤖 Generated with Claude Code

…d open (#996)

Clicking a text-only cell in the export wizard's audio-stats popover is
supposed to open the source+target editors at that cell's chapter/verse.
When the book was not already open, it instead opened at chapter 1.

openCodexDocumentWithSourcePair waited for the source pane's webview to be
ready but not the target .codex pane. Callers publish the navigation jump
(the `cellToJumpTo` workspace-state key) immediately after this helper
returns; the per-editor jump listener is registered while the editor
resolves, and waitForWebviewReady only returns once a pane has signalled
ready. With the target pane not waited for, a cold-opened editor could miss
the jump and fall back to its default page (chapter 1). When the book was
already open (warm), both panes were ready, so it worked.

Resolve the provider once and wait for BOTH panes (source and target) to be
ready before returning, in the normal path, the source-failed fallback, and
the no-workspace path. Cold-open now behaves like warm-open.

Fixes #996

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When clicking on cells without audio proper chapter doesn't open

1 participant