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

Context not working sometimes #556

Open
adriangalilea opened this issue May 2, 2024 · 5 comments
Open

Context not working sometimes #556

adriangalilea opened this issue May 2, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@adriangalilea
Copy link

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 adriangalilea added the bug Something isn't working label May 2, 2024
@adriangalilea
Copy link
Author

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.

@kdheepak
Copy link
Owner

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:

info!("Running `{:?}`", task);

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:

taskwarrior-tui/src/app.rs

Lines 1698 to 1706 in cfedca0

if !self.current_context_filter.trim().is_empty() && self.task_version >= *TASKWARRIOR_VERSION_SUPPORTED {
if let Some(args) = shlex::split(&self.current_context_filter) {
for arg in args {
task.arg(arg);
}
}
} else if !self.current_context_filter.trim().is_empty() {
task.arg(format!("'\\({}\\)'", self.current_context_filter));
}

@adriangalilea
Copy link
Author

adriangalilea commented May 12, 2024

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

@TIAcode
Copy link

TIAcode commented Aug 22, 2024

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
Copy link

TIAcode commented Aug 23, 2024

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.

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

3 participants