Skip to content

Prevent stuck positronHelpFocused context key from hijacking copy#13158

Open
juliasilge wants to merge 3 commits intomainfrom
free-up-help-focus
Open

Prevent stuck positronHelpFocused context key from hijacking copy#13158
juliasilge wants to merge 3 commits intomainfrom
free-up-help-focus

Conversation

@juliasilge
Copy link
Copy Markdown
Contributor

Addresses the part of #9364 that is about Positron Help focus, not about the upstream problem

The positronHelpFocused context key can apparently sometimes get stuck at true when the Help webview's onDidBlur event fails to fire (pane collapse, release() with retainContextWhenHidden, iframe navigation races). With the key stuck true, Cmd/Ctrl+C resolved to positron.help.copy instead of the normal copy command. This breaks user copy/paste anywhere in the workbench until a new help page was loaded to "jiggle" the focus cycle back into alignment. I still have not been able to reproduce the problem myself, so the changes in this PR are somewhat speculative.

The PR does two things:

  • Defensively clears positronHelpFocused to false in HelpEntry.dispose() and HelpEntry.hideHelpOverlayWebview(), independent of whether the webview fires blur.
  • Routes all writes to the context key through a small helper that logs transitions via ILogService, tagged [positronHelpFocused]. Logs land in the Window output channel and are captured in diagnostic reports. If people still have trouble moving forward, we can hopefully diagnose the underlying root cause a bit better moving forward.

A follow-up could switch the focus tracking to DOM.trackFocus() on the Help container (the pattern the Console
uses) to eliminate the failure mode entirely but this PR is just a minimal mitigation plus the data we'd need to justify a larger change.

Release Notes

New Features

  • N/A

Bug Fixes

QA Notes

@:help @:web @:win

  1. Open Positron with an R or Python session.
  2. Run ?lm (R) or help(print) (Python). Confirm the help page renders in the Help pane.
  3. Click into the help body so it has keyboard focus.
  4. Click into the console, select some text, and press Cmd/Ctrl+C. Confirm the text is copied (not hijacked by the Help copy command).
  5. Open View → Output → Window and look for [positronHelpFocused] lines on focus transitions, e.g., "webview.onDidFocus: false -> true" and "webview.onDidBlur: true -> false".
  6. Collapse the Help pane while it's focused, then re-expand it. Confirm help still renders, Cmd/Ctrl+C still works elsewhere, and the log shows a "hideHelpOverlayWebview(dispose=false): true -> false" transition.
  7. Navigate between help topics (e.g., ?lm then ?glm). Confirm each entry renders and logs show clean focus/blur cycles.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:help @:web @:win

readme  valid tags

@juliasilge juliasilge marked this pull request as ready for review April 23, 2026 03:28
@juliasilge juliasilge requested a review from softwarenerd April 23, 2026 03:28
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.

1 participant