Skip to content

Add help on F1 keystroke#1627

Open
rolandwalker wants to merge 1 commit intomainfrom
RW/add-help-on-f1
Open

Add help on F1 keystroke#1627
rolandwalker wants to merge 1 commit intomainfrom
RW/add-help-on-f1

Conversation

@rolandwalker
Copy link
Contributor

Description

  • open documentation index in web browser on F1
  • emit output using prompt_toolkit methods such that the prompt is restored including pending input
  • include the docs URL in the output in case the browser did not open
  • include alternate F1 key sequence that prompt_toolkit doesn't handle
  • update TIPS and key_bindings.rst

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Feb 25, 2026
@github-actions
Copy link

Findings

  1. Potential prompt corruption + uncaught exceptions from browser launch
    webbrowser.open_new_tab() is invoked outside run_in_terminal and without error handling. If the browser command writes to stdout/stderr or raises (common on headless systems), this can corrupt the prompt or bubble exceptions into the key handler. Consider wrapping the browser call inside run_in_terminal and catching webbrowser.Error/OSError so F1 never destabilizes the UI.
    File: mycli/key_bindings.py:51 and mycli/key_bindings.py:58

Missing tests / edge cases

  1. No coverage for the new F1 behavior
    There are no tests asserting that the F1 binding emits help text and attempts a browser open. A lightweight unit test could monkeypatch webbrowser.open_new_tab and prompt_toolkit.application.run_in_terminal to assert both are called, and that failures don’t raise.
    File: mycli/key_bindings.py:51 and mycli/key_bindings.py:58

If you want, I can sketch a minimal pytest for this.

 * open documentation index in web browser
 * emit output using prompt_toolkit methods such that the prompt is
   restored including pending input
 * include the docs URL in the output in case the browser did not open
 * include alternate F1 key sequence that prompt_toolkit doesn't handle
 * update TIPS and key_bindings.rst
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