Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Pasting workspaces causes program to crash and pasted workspace to be removed #174

Open
Pairadux opened this issue Mar 8, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@Pairadux
Copy link

Pairadux commented Mar 8, 2024

Describe the bug 🐛
Upon copying and pasting workspaces, using the directional keys 'j' or 'k' causes the program to crash and the recently pasted workspace to be removed.

See additional context at the bottom for a "fix/bypass" I discovered.

To Reproduce 🐣
Steps to reproduce the behavior:

  1. Open application
  2. Press 'a' to create a workspace
  3. Enter description for newly created workspace
    -- START OF EDIT
  4. Press 'tab' to move to TODOS
  5. Press 'a' to create a new task
  6. Enter description for newly created task
  7. Press 'tab' to move back to WORKSPACES
    -- END OF EDIT
  8. Hover over / highlight newly created workspace
  9. Press 'y' to copy workspace to clipboard
  10. Press 'p' to paste workspace
  11. Press either the 'j' or 'k' key to move up or down

Expected behavior 🤔
The workspace should be able to be pasted without the program crashing and the workspace being removed.

Screenshots 🧐
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): 🤖

  • OS: Linux Mint
  • Version 21.3

Additional context 📝
A "fix/bypass" I found was that, upon pasting the workspace, if you press 'tab' to enter the workspace, and press 'a' to create a task, followed by adding the description of the task, when you press 'tab' again to return to the workspace selection pane, upon using 'j' or 'k' the program will still crash, but the workspace will still be there with the newly added task.

@Pairadux Pairadux added the bug Something isn't working label Mar 8, 2024
@Pairadux Pairadux changed the title [BUG] [BUG] Pasting workspaces causes program to crash and pasted workspace to be removed Mar 8, 2024
@kraanzu
Copy link
Member

kraanzu commented Mar 9, 2024

Hmm... Not sure If I'm replicating the same bug. Can you paste the error? Thanks!

@Pairadux
Copy link
Author

Pairadux commented Mar 9, 2024

Hey, I did some more testing to figure out why replicating the bug wasn't working, I have updated my original comment to include everything necessary to replicate the bug, but I will also include the error.

╭──────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────────────╮
│ /Users/austingause/.pyenv/versions/3.12.0/lib/python3.12/site-packages/dooit/ui/screens/index.py:59 in on_key                                                                      │
│                                                                                                                                                                                    │
│    56 │   │   event.stop()                                                                     ╭───────────────────────────── locals ─────────────────────────────╮                │
│    57 │   │                                                                                    │ event = Key(key='k', character='k', name='k', is_printable=True) │                │
│    58 │   │   key = self.resolve_key(event)                                                    │   key = 'k'                                                      │                │
│ ❱  59 │   │   await self.send_keypress(key)                                                    │  self = MainScreen(name='main')                                  │                │
│    60 │                                                                                        ╰──────────────────────────────────────────────────────────────────╯                │
│    61async def send_keypress(self, key: str):                                                                                                                                 │
│    62 │   │   if self.bar.status == "SEARCH":                                                                                                                                      │
│                                                                                                                                                                                    │
│ /Users/austingause/.pyenv/versions/3.12.0/lib/python3.12/site-packages/dooit/ui/screens/index.py:66 in send_keypress                                                               │
│                                                                                                                                                                                    │
│    63 │   │   │   return await self.query_one(Searcher).keypress(key)                                                                                                              │
│    64 │   │                                                                                                                                                                        │
│    65 │   │   visible_focused = [i for i in self.query(".focus") if i.display][0]                                                                                                  │
│ ❱  66 │   │   await visible_focused.keypress(key)                                                                                                                                  │
│    67 │                                                                                                                                                                            │
│    68async def clear_right(self) -> None:                                                                                                                                     │
│    69 │   │   try:                                                                                                                                                                 │
│                                                                                                                                                                                    │
│ ╭──────────────────────────────────────── locals ─────────────────────────────────────────╮                                                                                        │
│ │             key = 'k'                                                                   │                                                                                        │
│ │            self = MainScreen(name='main')                                               │                                                                                        │
│ │ visible_focused = WorkspaceTree(id='Tree-manager_4a33b675-3694-404b-9d37-975a8cdf3ea3') │                                                                                        │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────╯                                                                                        │
│                                                                                                                                                                                    │
│ /Users/austingause/.pyenv/versions/3.12.0/lib/python3.12/site-packages/dooit/ui/widgets/tree.py:521 in keypress                                                                    │
│                                                                                                                                                                                    │
│   518 │   │   if self.current and self.current._is_editing():                                  ╭─────────────────────────────────── locals ───────────────────────────────────╮    │
│   519 │   │   │   return await self.current.keypress(key)                                      │  key = 'k'                                                                   │    │
│   520 │   │                                                                                    │ self = WorkspaceTree(id='Tree-manager_4a33b675-3694-404b-9d37-975a8cdf3ea3') │    │
│ ❱ 521 │   │   await super().keypress(key)                                                      ╰──────────────────────────────────────────────────────────────────────────────╯    │
│   522                                                                                                                                                                              │
│                                                                                                                                                                                    │
│ /Users/austingause/.pyenv/versions/3.12.0/lib/python3.12/site-packages/dooit/ui/widgets/base.py:42 in keypress                                                                     │
│                                                                                                                                                                                    │
│   39 │   │   │   │   if bind.check_for_cursor and not self.is_cursor_available:                                                                                                    │
│   40 │   │   │   │   │   return                                                                                                                                                    │
│   41 │   │   │   │                                                                                                                                                                 │
│ ❱ 42 │   │   │   │   res = await func(*bind.params)                                                                                                                                │
│   43 │   │   │   │   if isinstance(res, Result) and res.message:                                                                                                                   │
│   44 │   │   │   │   │   self.post_message(Notify(res.text()))                                                                                                                     │
│   45                                                                                                                                                                               │
│                                                                                                                                                                                    │
│ ╭────────────────────────────────────────────────── locals ───────────────────────────────────────────────────╮                                                                    │
│ │ bind = <dooit.utils.keybinder.Bind object at 0x106898800>                                                   │                                                                    │
│ │ func = <bound method Tree.move_up of WorkspaceTree(id='Tree-manager_4a33b675-3694-404b-9d37-975a8cdf3ea3')> │                                                                    │
│ │  key = 'k'                                                                                                  │                                                                    │
│ │ self = WorkspaceTree(id='Tree-manager_4a33b675-3694-404b-9d37-975a8cdf3ea3')                                │                                                                    │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                    │
│                                                                                                                                                                                    │
│ /Users/austingause/.pyenv/versions/3.12.0/lib/python3.12/site-packages/dooit/ui/widgets/tree.py:365 in move_up                                                                     │
│                                                                                                                                                                                    │
│   362 │   │   │   self.current = node                                                          ╭─────────────────────────────────── locals ───────────────────────────────────╮    │
│   363 │                                                                                        │ self = WorkspaceTree(id='Tree-manager_4a33b675-3694-404b-9d37-975a8cdf3ea3') │    │
│   364async def move_up(self) -> None:                                                     ╰──────────────────────────────────────────────────────────────────────────────╯    │
│ ❱ 365 │   │   if node := self.prev_node():                                                                                                                                         │
│   366 │   │   │   self.current = node                                                                                                                                              │
│   367 │                                                                                                                                                                            │
│   368async def move_to_top(self) -> None:                                                                                                                                     │
│                                                                                                                                                                                    │
│ /Users/austingause/.pyenv/versions/3.12.0/lib/python3.12/site-packages/dooit/ui/widgets/tree.py:248 in prev_node                                                                   │
│                                                                                                                                                                                    │
│   245 │   │   if not self.current:                                                                                                                                                 │
│   246 │   │   │   return                                                                                                                                                           │
│   247 │   │                                                                                                                                                                        │
│ ❱ 248 │   │   idx = nodes.index(self.current)                                                                                                                                      │
│   249 │   │   if not idx:                                                                                                                                                          │
│   250 │   │   │   return                                                                                                                                                           │
│   251                                                                                                                                                                              │
│                                                                                                                                                                                    │
│ ╭───────────────────────────────────── locals ──────────────────────────────────────╮                                                                                              │
│ │ nodes = [                                                                         │                                                                                              │
│ │         │   WorkspaceWidget(                                                      │                                                                                              │
│ │         │   │   id='workspace_f079751c-ece2-4ab1-86d6-73833484eabf'               │                                                                                              │
│ │         │   ),                                                                    │                                                                                              │
│ │         │   WorkspaceWidget(                                                      │                                                                                              │
│ │         │   │   id='workspace_93a44e4b-4a11-4bdd-9c75-0804106ee901'               │                                                                                              │
│ │         │   ),                                                                    │                                                                                              │
│ │         │   WorkspaceWidget(                                                      │                                                                                              │
│ │         │   │   id='workspace_159155c6-019f-45bf-a01d-60f060dbe249'               │                                                                                              │
│ │         │   ),                                                                    │                                                                                              │
│ │         │   WorkspaceWidget(                                                      │                                                                                              │
│ │         │   │   id='workspace_474c34d8-8aba-4a13-8384-bccb9fcf8fe5'               │                                                                                              │
│ │         │   )                                                                     │                                                                                              │
│ │         ]                                                                         │                                                                                              │
│ │  self = WorkspaceTree(id='Tree-manager_4a33b675-3694-404b-9d37-975a8cdf3ea3')     │                                                                                              │
│ ╰───────────────────────────────────────────────────────────────────────────────────╯                                                                                              │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: WorkspaceWidget(id='workspace_c43fcc53-d086-4c38-941a-154ef145e852') is not in list

@kraanzu
Copy link
Member

kraanzu commented Mar 10, 2024

Thanks for the details!

I think I may have found a fix but not sure since for some weird reason, I can't replicate the bug most of the time (It works sometimes)
What are you using to install the app?

kraanzu added a commit that referenced this issue Mar 10, 2024
@Pairadux
Copy link
Author

If I'm not mistaken, I used pip to install it both on my MacBook and my Linux desktop, and am also able to get the error to appear on both, with a roughly 70%~ rate of the bug appearing. It is certainly an interesting issue.

@kraanzu
Copy link
Member

kraanzu commented Mar 10, 2024

Can you try pip installing using this:

pip install git+https://github.com/kraanzu/dooit.git@develop

and let me know if it fixes it.
Thanks :)

@Pairadux
Copy link
Author

Yeah no problem, will give it a shot when I get a chance and update the thread when I am able to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants