tconbeer / harlequin

The SQL IDE for Your Terminal.

Home Page:https://harlequin.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linux: clipboard on wayland doesn't work

SalmanFarooqShiekh opened this issue · comments

Before Proceeding, please acknowledge:

  • I have consulted the Troubleshooting guide, specifically the Copy-Paste section.
  • I have searched Issues and Discussions in this repo.
  • Feature requests should be initiated as Discussions. This is a bug report.

Describe the bug
Copying text in query editor or query results on wayland compositors with no Xwayland shows an error message: "Could not access system clipboard.". With Xwayland, everything works fine without changing anything.

To Reproduce

  1. Install and start a session of a wayland compositor which doesn't have Xwayland support e.g. niri
  2. Open a terminal window e.g. kitty
  3. Run harlequin duck.db
  4. Type some text in the query editor
  5. Select it with mouse or shift + arrow-keys
  6. Hit control + c
  7. Said error appears in the bottom right corner

Expected behavior
Text is copied with no error notification

Actual behavior
An error shows up and text is not copied.
image

Contributing
Are you interested in contributing a fix?

  • Yes (I think this is due to a dependency on xsel/xclip which only works on X11. I can contribute a fix which will use wl-clipboard instead when XDG_SESSION_TYPE is equal to 'wayland' Upon reading the code, it seems like the TUI library component textual-textarea might need updating to fix this issue)
  • Maybe
  • No

Additional context
Not relevant.

What is the output of harlequin --version?

harlequin, version 1.21.0

Installed Adapters:
  - mysql, version 0.1.3
  - odbc, version 0.1.1
  - trino, version 0.1.3
  - databricks, version 0.1.1
  - bigquery, version 1.0.2
  - adbc, version 0.1.1
  - duckdb, version 1.21.0
  - sqlite, version 1.21.0
  - postgres, version 0.2.2

What database adapter are you using with Harlequin? (Default is duckdb)
I have tried postgres and duckdb, error is present with both.

What other options are you using when invoking Harlequin? (If you are using a profile, please add relevant items from your profile here).
Not relevant.

Can you tell us more about your system?

  • Shell: fish
  • Terminal: kitty
  • OS of the shell: Arch Linux
  • OS of the terminal (if different from the shell): Arch Linux
  • Default locale / language for your OS/Terminal/Shell: echo $LC_ALL gives en_US.utf8

Tip

For example, for my system, these are:

  • Bash
  • Windows Terminal
  • Ubuntu 22.04 / WSL2
  • Windows 11
  • en_US/UTF-8

How did you install Harlequin?

  • pipx
  • conda/mamba
  • pip (global install)
  • pip + venv/virtualenv or pipenv
  • Poetry
  • uv/Rye
  • other: _____________

It looks like there is a fix for this already upstream (this PR was closed but it was implemented in another commit): asweigart/pyperclip#201

It is probably enough to just bump our pyperclip dependency to the version released last week, v1.9.0

I just edited my original post to say something similar just before your comment :)

Anyways, I know it was a bit hasty on my part but I have already set up the dev environment for harlequin locally on my machine so if you want me to do this and possibly handle any breaking changes to pyperclip, I can do it. Let me know. Thanks.

@SalmanFarooqShiekh all good -- I just opened a PR in an upstream project for the textarea widget, which is where Harlequin accesses the clipboard. Once I merge and release that, if you could bump the version of textual-textarea in your local harlequin, that would confirm the fix.

ok, textual-textarea v0.13.1 has been released

testing

 1 diff --git a/pyproject.toml b/pyproject.toml
  2 index f903579..b085e22 100644
  3 --- a/pyproject.toml
  4 +++ b/pyproject.toml
  5 @@ -24,7 +24,7 @@ python = ">=3.8.1,<4.0.0"
  6  # textual and component libraries
  7  textual = "==0.56.4"
  8  textual-fastdatatable = "==0.7.1"
  9 -textual-textarea = "==0.13.0"
 10 +textual-textarea = "==0.13.1"
 11  
 12  # click
 13  click = "^8.1.3"

Getting this error:

$ poetry install --sync
Installing dependencies from lock file

pyproject.toml changed significantly since poetry.lock was last generated. Run `poetry lock [--no-update]` to fix the lock file.

$ poetry lock
Updating dependencies
Resolving dependencies... (74.3s)

Because no versions of textual match >0.60,<0.60.1 || >0.60.1,<0.61
 and textual[syntax] (0.60.0) depends on textual (0.60.0), textual[syntax] (>=0.60,<0.60.1 || >0.60.1,<0.61) requires textual (0.60.0).
And because textual[syntax] (0.60.1) depends on textual (0.60.1)
 and textual-textarea (0.13.1) depends on textual[syntax] (>=0.60,<0.61), textual-textarea (0.13.1) requires textual (0.60.0 || 0.60.1).
So, because harlequin depends on both textual (==0.56.4) and textual-textarea (==0.13.1), version solving failed.

Sorry I haven't done python in a while and poetry never.

Oh, my bad. Looks like I updated something I shouldn't have in the other project

Any way I can help?

Thanks for the offer. No, I need to bump the version of textual we're running in Harlequin. That can be tricky, but I should be able to fight through it next week