Context not working sometimes
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
My context is side-quest could it be because of the "-"??
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.
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
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
taskwarrior-tui output
Using context.default.read='(project.not:side-quest and tags.not:side-quest)' or urgency>5 as context tests:
task output
taskwarrior-tui output
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)
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.
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
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
has this been fixed on main?
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.