marvin
marvin copied to clipboard
TUI crashes when trying to copy a message if you are running on a headless system with no clipboard
First check
- [X] I added a descriptive title to this issue.
- [X] I used the GitHub search to try to find a similar issue and didn't find one.
- [X] I searched the Marvin documentation for this issue.
Bug summary
I have Marvin installed on a Linux system that is running headless. I am SSH'ed into that system. The TUI works great in most respects, but if you try to copy a message, the TUI crashes due to the lack of a clipboard provider. Instead, it should simply report an error to the user in a dialog without crashing.
Reproduction
1. Use `marvin chat` on a system with no clipboard provider running and generate some messages.
2. Try to copy a message via the "Copy" button in the TUI.
3. Marvin takes its toys and goes home.
Error
[05/17/23 07:03:06] INFO marvin.marvin: Using OpenAI model "gpt-3.5-turbo" logging.py:50
07:03:06.793 | INFO | marvin.marvin - [default on default]Using OpenAI model "gpt-3.5-turbo"[/]
WARNING marvin: 404 cli.py:86
07:03:06.899 | WARNING | marvin - 404
╭─────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────╮
│ /home/jwilger/.asdf/installs/python/3.11.2/lib/python3.11/site-packages/marvin/cli/tui.py:236 in on_button_pressed │
│ │
│ 233 │ │
│ 234 │ def on_button_pressed(self, event: Button.Pressed): │
│ 235 │ │ if event.button.id == "copy-message": │
│ ❱ 236 │ │ │ pyperclip.copy(self.message.content) │
│ 237 │ │ │ self.action_toggle_buttons() │
│ 238 │ │ │
│ 239 │ │ elif event.button.id == "delete-message": │
│ │
│ ╭────────────────────────────────────────────────────────── locals ──────────────────────────────────────────────────────────╮ │
│ │ event = Pressed() │ │
│ │ self = BotResponse(classes={'bot-response', 'response', 'show-edit-buttons'}, pseudo_classes={'focus-within', 'enabled'}) │ │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/jwilger/.asdf/installs/python/3.11.2/lib/python3.11/site-packages/pyperclip/__init__.py:659 in lazy_load_stub_copy │
│ │
│ 656 │ ''' │
│ 657 │ global copy, paste │
│ 658 │ copy, paste = determine_clipboard() │
│ ❱ 659 │ return copy(text) │
│ 660 │
│ 661 │
│ 662 def lazy_load_stub_paste(): │
│ │
│ ╭────────────────────────────────────────────── locals ──────────────────────────────────────────────╮ │
│ │ text = 'Sure, here are the updated instructions:\n\nInstructions:\n\n1. When you start Pear,'+2149 │ │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/jwilger/.asdf/installs/python/3.11.2/lib/python3.11/site-packages/pyperclip/__init__.py:336 in __call__ │
│ │
│ 333 │ class ClipboardUnavailable(object): │
│ 334 │ │ │
│ 335 │ │ def __call__(self, *args, **kwargs): │
│ ❱ 336 │ │ │ raise PyperclipException(EXCEPT_MSG) │
│ 337 │ │ │
│ 338 │ │ if PY2: │
│ 339 │ │ │ def __nonzero__(self): │
│ │
│ ╭──────────────────────────────────────────────── locals ─────────────────────────────────────────────────╮ │
│ │ args = ('Sure, here are the updated instructions:\n\nInstructions:\n\n1. When you start Pear,'+2149,) │ │
│ │ kwargs = {} │ │
│ │ self = <pyperclip.init_no_clipboard.<locals>.ClipboardUnavailable object at 0x7f2a403c7010> │ │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
PyperclipException:
Pyperclip could not find a copy/paste mechanism for your system.
For more information, please visit https://pyperclip.readthedocs.io/en/latest/index.html#not-implemented-error
Versions
$ marvin version [6:51:39]
[05/17/23 06:58:43] INFO marvin.marvin: Using OpenAI model "gpt-3.5-turbo" logging.py:50
06:58:43.472 | INFO | marvin.marvin - [default on default]Using OpenAI model "gpt-3.5-turbo"[/]
0.9.0
Additional context
No response