Skip to content

feat: DH-22990: improve clear command behaviour in console input#2709

Open
dsmmcken wants to merge 2 commits into
mainfrom
dmckenzie_clear
Open

feat: DH-22990: improve clear command behaviour in console input#2709
dsmmcken wants to merge 2 commits into
mainfrom
dmckenzie_clear

Conversation

@dsmmcken

@dsmmcken dsmmcken commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Typing clear/cls in the console was unreliable — Monaco autocomplete would hijack Enter with a fuzzy match instead of running the command. This makes clearing the console reliable and discoverable.

  • a single enter now always runs clear/cls even with the suggest widget open
  • clear/cls now show in autocomplete (without suppressing word-based suggestions).
  • added "Clear" to the console overflow menu
  • added cmd/ctrl+l shortcut (updates live when rebound in settings), replacing previous shortcut that was supposed to clear the input but didn't actually do anything because monaco ate it

Not tested on mac. Please test.

Not sure how much gets reused in enterprise of this.

@dsmmcken
dsmmcken requested a review from mofojed June 26, 2026 21:23
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 26.47059% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.86%. Comparing base (0c7d87c) to head (a0df86a).

Files with missing lines Patch % Lines
packages/console/src/ConsoleInput.tsx 36.84% 12 Missing ⚠️
packages/console/src/monaco/MonacoProviders.tsx 0.00% 7 Missing ⚠️
packages/console/src/Console.tsx 25.00% 3 Missing ⚠️
packages/console/src/ClearCommands.ts 33.33% 2 Missing ⚠️
packages/console/src/monaco/MonacoUtils.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2709      +/-   ##
==========================================
- Coverage   51.10%   50.86%   -0.25%     
==========================================
  Files         793      794       +1     
  Lines       45204    45228      +24     
  Branches    11703    11510     -193     
==========================================
- Hits        23103    23003     -100     
- Misses      22055    22206     +151     
+ Partials       46       19      -27     
Flag Coverage Δ
unit 50.86% <26.47%> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mofojed

mofojed commented Jun 30, 2026

Copy link
Copy Markdown
Member

@dsmmcken not sure this is the "right" fix. As I commented on the ticket, native Python REPL in Python just sends the command when you press Enter: https://deephaven.atlassian.net/browse/DH-22990?focusedCommentId=73600
You press Tab to autocomplete.
We should probably do the same, as it's annoying to hit Esc then Enter to just enter stuff.

@mofojed mofojed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The registered suggestions don't appear.

I really don't like this change. It's unexpected behaviour - if I have a variable named clear_color or cls_name, and then type cls and press "Enter", it will just clear my console instead of picking that variable name (which is different behaviour than before, and different behaviour than if you had typed literally anything else).

As mentioned, I really think we should just take "Enter" to run the current command, "Tab" to take the suggestion, as other Python REPLs do.
OR correctly add the clear and cls as commands in the autosuggestion, so you need to press Enter to get the suggestion, then Enter again to send it.

Note also looked at Chrome console and Firefox Console.
Chrome console just runs the command on Enter. It doesn't autohighlight the first suggestion, and shows tab in it to get the suggestion:
Image
If you press Down on the keyboard, then it highlights it:
Image

Firefox shows the item highlighted, and when you press Enter, it selects that item.
Image

// Register the special console commands (clear/cls) as completions. Uses the
// '*' selector so it shares Monaco's low-priority word-based completion group
// and coexists with it, instead of suppressing word-based suggestions.
monaco.languages.registerCompletionItemProvider('*', {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to work. I think it just most specific completion provider available, as I just see the regular suggestions. If I comment out the other registration (e.g. in MonacoProviders), I then see these suggestions.

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.

2 participants