taskwarrior-tui icon indicating copy to clipboard operation
taskwarrior-tui copied to clipboard

Context not working sometimes

Open adriangalilea opened this issue 1 year ago • 9 comments

Reproduction

$ task

ID  project             description                                                                                      tags p urg     
138 side-quest.e-id     redacted                                                                                                  0.5
117 side-quest.e-id.dev redacted                                                              0.5
118 side-quest.e-id.dev redacted                                   0.5
  2 side-quest.e-id     redacted                                                                       0.5
  8 side-quest.e-id     redacted L -0.00466

$ taskwarrior-tui

image

My context is side-quest could it be because of the "-"??

adriangalilea avatar May 02 '24 20:05 adriangalilea

I can guarantee that taskwarrior-tui doesn't interpret context as taskwarrior does, for instance:

context.default.read="(project.not:side-quest and tags.not:side-quest)" or urgency>5

Will work on taskwarrior-tui but fail on taskwarrior, and:

context.default.read=(project.not:side-quest and tags.not:side-quest) or urgency>5

Will work on taskwarrior but fail on taskwarrior-tui.

So I can either use one or the other, not both.

adriangalilea avatar May 10 '24 15:05 adriangalilea

When you say it fails in taskwarrior-tui, does it error? Or does it just not display the correct tasks?

taskwarrior-tui calls task export as a subprocess (i.e. std::process::Command) and reads the json.

You can look at the log files of taskwarrior-tui to see the exact subprocess that is created and executed by taskwarrior-tui:

https://github.com/kdheepak/taskwarrior-tui/blob/cfedca0ad1c765dfce46576a86f1bd19b6beaec8/src/app.rs#L1714

Maybe that'll help narrow down what is going on?

I'm assuming it has something to do with how the context string is spliced into the subprocess when tasks are exported:

https://github.com/kdheepak/taskwarrior-tui/blob/cfedca0ad1c765dfce46576a86f1bd19b6beaec8/src/app.rs#L1698-L1706

kdheepak avatar May 10 '24 17:05 kdheepak

logging

❯ export TASKWARRIOR_TUI_LOG_LEVEL=debug
❯ taskwarrior-tui

Does not show me any logs unless they are somewhere I'm unfamiliar with.

clarifying bug

When you say it fails in taskwarrior-tui, does it error? Or does it just not display the correct tasks?

I'm having some inconsistencies, over iterations(slightly modified context) I had 3 different results:

  • Seeing an error, I don't remember which one.
  • Showing the list of all tasks despite filtering fine in taskwarrior via "task"
  • (CURRENT) Showing an empty list of tasks, despite filtering fine in taskwarrior via "task"

Using context.default.read=(project.not:side-quest and tags.not:side-quest) or urgency>5 as context tests:

task output image

taskwarrior-tui output image

Using context.default.read='(project.not:side-quest and tags.not:side-quest)' or urgency>5 as context tests:

task output image

taskwarrior-tui output image

adriangalilea avatar May 12 '24 10:05 adriangalilea

I've ran into the same problem.

diff /.snapshots/home-20240822_060000/user/.taskrc ~/.taskrc
46c46
< context.main.read=((tag:birthday and due.before:now+1month) or (-birthday)) and ((tag:holiday and due.before:now+1week) or (-holiday)) and project.not:ddd
---
> context.main.read=((tag:birthday and due.before:now+1month) or (-birthday)) and ((tag:holiday and due.before:now+1week) or (-holiday)) and (project.not:ddd and project.not:wfc)

This small change made taskwarrior show only 'Task not found". Using the context with task works. The log is

2024-08-22 08:42:47 | INFO | src/app.rs:1723 | Running `Command {
    program: "task",
    args: [
        "task",
        "rc.json.array=on",
        "rc.confirmation=off",
        "rc.json.depends.array=on",
        "rc.color=off",
        "rc._forcecolor=off",
        "rc.report.next.filter=status:pending -WAITING",
        "((tag:birthday",
        "and",
        "due.before:now+1month)",
        "or",
        "(-birthday))",
        "and",
        "((tag:holiday",
        "and",
        "due.before:now+1week)",
        "or",
        "(-holiday))",
        "and",
        "(project.not:ddd",
        "and",
        "project.not:wfc)",
        "export",
        "next",
    ],
    create_pidfd: false,
}`

I don't know if it helps anything, but copying these for python's subprocess, the one given by taskwarrior-tui fails with Mismatched parentheses in expression, but if I combine the context filter to one argument, it works:

>>> x=[
...         "task",
...         "rc.json.array=on",
...         "rc.confirmation=off",
...         "rc.json.depends.array=on",
...         "rc.color=off",
...         "rc._forcecolor=off",
...         "rc.report.next.filter=status:pending -WAITING",
...         "((tag:birthday",
...         "and",
...         "due.before:now+1month)",
...         "or",
...         "(-birthday))",
...         "and",
...         "((tag:holiday",
...         "and",
...         "due.before:now+1week)",
...         "or",
...         "(-holiday))",
...         "and",
...         "(project.not:ddd",
...         "and",
...         "project.not:wfc)",
...         "export",
...         "next",
...     ]
>>> z=subprocess.run(x,capture_output=True)
>>> z
CompletedProcess(args=['task', 'rc.json.array=on', 'rc.confirmation=off', 'rc.json.depends.array=on', 'rc.color=off', 'rc._forcecolor=off', 'rc.report.next.filter=status:pending -WAITING', '((tag:birthday', 'and', 'due.before:now+1month)', 'or', '(-birthday))', 'and', '((tag:holiday', 'and', 'due.before:now+1week)', 'or', '(-holiday))', 'and', '(project.not:ddd', 'and', 'project.not:wfc)', 'export', 'next'], returncode=2, stdout=b'', stderr=b'Configuration override rc.json.array=on\nConfiguration override rc.confirmation=off\nConfiguration override rc.json.depends.array=on\nConfiguration override rc.color=off\nConfiguration override rc._forcecolor=off\nConfiguration override rc.report.next.filter=status:pending -WAITING\nMismatched parentheses in expression\n')
>>> x2=[
...         "task",
...         "rc.json.array=on",
...         "rc.confirmation=off",
...         "rc.json.depends.array=on",
...         "rc.color=off",
...         "rc._forcecolor=off",
...         "rc.report.next.filter=status:pending -WAITING",
...         "((tag:birthday " +
...         "and " +
...         "due.before:now+1month) " +
...         "or " +
...         "(-birthday)) " +
...         "and " +
...         "((tag:holiday " +
...         "and " +
...         "due.before:now+1week) " +
...         "or " +
...         "(-holiday)) " +
...         "and " +
...         "(project.not:ddd " +
...         "and " +
...         "project.not:wfc)",
...         "export",
...         "next",
...     ]
>>> z2=subprocess.run(x2,capture_output=True)
>>> z2
CompletedProcess(args=['task', 'rc.json.array=on', 'rc.confirmation=off', 'rc.json.depends.array=on', 'rc.color=off', 'rc._forcecolor=off', 'rc.report.next.filter=status:pending -WAITING', '((tag:birthday and due.before:now+1month) or (-birthday)) and ((tag:holiday and due.before:now+1week) or (-holiday)) and (project.not:ddd and project.not:wfc)', 'export', 'next'], returncode=0, stdout=b'[\n{"id":43,"description":.......(all the tasks)

TIAcode avatar Aug 22 '24 01:08 TIAcode

Had time to test it

      //if let Some(args) = shlex::split(&self.current_context_filter) {
      //  for arg in args {
      //    task.arg(arg);
      //  }
      //}
      task.arg(self.current_context_filter.trim());

src/app.rs, I changed that starting from line 1694 and it seems to work.

TIAcode avatar Aug 23 '24 08:08 TIAcode

Leaving a permalink reference here so its easy to find if there's a drift

https://github.com/kdheepak/taskwarrior-tui/blob/54b06cd20e85baf5a6e4550048c0cd18f2c26ace/src/app.rs#L1686-L1690

igbanam avatar Mar 07 '25 01:03 igbanam

I would say though, the context behaviours for both task and the -tui seem to agree when the context is a simple project filter

task context define some-context project:my-project

igbanam avatar Mar 07 '25 01:03 igbanam

has this been fixed on main?

adriangalilea avatar Apr 22 '25 13:04 adriangalilea

Probably not. I think commenting those lines will break some other issues. Unfortunately I haven't had time to work on this and look into this further.

kdheepak avatar Apr 23 '25 07:04 kdheepak