taskwarrior icon indicating copy to clipboard operation
taskwarrior copied to clipboard

Tag coefficient not applied when multiple tags exist on a task

Open davidolrik opened this issue 1 year ago • 10 comments

Given the following configuration:

data.location=.
hooks.location=./hooks

urgency.uda.tags.foo.coefficient=10
urgency.uda.tags.bar.coefficient=5

We can show that the tag coefficient is not applied when more than one tag exists on a task.

To see the problem in action create a taskrc file with the above config in an empty directory and run the following commands:

# Create task with one tag and now additional urgency
$ task rc:taskrc add Test +baz
TASKRC override: taskrc
Created task 1.

# Show list of tasks where urgency is as expected
$ task rc:taskrc
TASKRC override: taskrc

ID Age   Tag Description Urg
 1 14s   baz Test         0.8

1 task

# Add tag bar, expecting the urgency to go up
$ task rc:taskrc 1 modify +bar
Modifying task 1 'Test'.
Modified 1 task.
TASKRC override: taskrc
$ task rc:taskrc
TASKRC override: taskrc

ID Age  Tag     Description Urg
 1 2min bar baz Test         0.9

1 task

# Show task 1 (With non-important part stripped out) - urgency did not go up
$ task rc:taskrc 1
TASKRC override: taskrc

Name          Value
ID            1
Urgency       0.9
[tag_bar      x]
[tag_baz      x]

    tags    0.9 *    1 =    0.9
                         ------
                            0.9

# Remove tag baz, so only one tag with a coefficient is present
$ task rc:taskrc 1 modify -baz
Modifying task 1 'Test'.
Modified 1 task.
TASKRC override: taskrc

# Show task 1 (With non-important part stripped out)  - urgency is as expected
$ task rc:taskrc 1
TASKRC override: taskrc

Name          Value
ID            1
Urgency       5.8
[tag_bar      x]

    tags            0.8 *    1 =    0.8
    UDA tags.bar      1 *    5 =      5
                                 ------
                                    5.8

# Add second tag with coefficient - expecting urgency to be 15+
$ task rc:taskrc 1 modify +foo
Modifying task 1 'Test'.
Modified 1 task.
TASKRC override: taskrc

# Show task 1 (With non-important part stripped out) - urgency is incorrect
$ task rc:taskrc 1
TASKRC override: taskrc

Name          Value
ID            1
Description   Test
Status        Pending
Entered       2024-12-17 13:54:58 (7min)
Last modified 2024-12-17 14:01:53 (21s)
Tags          bar foo
Virtual tags  LATEST PENDING READY TAGGED UNBLOCKED
UUID          6cac55d8-89da-440d-b8e7-1aa676963fe5
Urgency       0.9
[tag_bar      x]
[tag_foo      x]

    tags    0.9 *    1 =    0.9
                         ------
                            0.9

Output of task diag

$ task rc:taskrc diag
TASKRC override: taskrc

task 3.1.0
   Platform: Darwin

Compiler
    Version: Apple LLVM 16.0.0 (clang-1600.0.26.3)
       Caps: +stdc +stdc_hosted +LP64 +c8 +i32 +l64 +vp64 +time_t64
 Compliance: C++17

Build Features
      CMake: 3.30.3
    libuuid: libuuid + uuid_unparse_lower
 Build type: Release

Configuration
       File: taskrc (found), 149 bytes, mode 100644
       Data: . (found), dir, mode 40755
         GC: Enabled
    $EDITOR: hx
Hooks
     System: Enabled
   Location: ./hooks
             (-none-)

Tests
   Terminal: 252x75
 Broken ref: Scanned 2 tasks for broken references:
             No broken references found

As a sidenote: My terminal is 170x61 and not 252x75 as seen in the diag output.

davidolrik avatar Dec 17 '24 13:12 davidolrik

Hi there,

Could you test by changing UDA to USER in .taskrc? It seems to work that way for me, I don't know if it fits in your specific case.

From:

urgency.uda.tags.foo.coefficient=10
urgency.uda.tags.bar.coefficient=5

To:

urgency.user.tags.foo.coefficient=10
urgency.user.tags.bar.coefficient=5

helderlgoliveira avatar May 04 '25 19:05 helderlgoliveira

From https://taskwarrior.org/docs/urgency/ it looks like it should just be urgency.tag.foo and urgency.tag.bar.

djmitche avatar May 04 '25 22:05 djmitche

(I'm going to close this old issue, but hopefully the above comments are helpful!)

djmitche avatar May 04 '25 22:05 djmitche

(I'm going to close this old issue, but hopefully the above comments are helpful!)

I tried both approaches and none of them worked.

When changing to .user or removing it it resulted in none of the coefficients were applied.

davidolrik avatar May 13 '25 13:05 davidolrik

Ok, so I played around with it some more, and found the solution:

urgency.user.tag.foo.coefficient=10
urgency.user.tag.bar.coefficient=5

Note no s in tag =)

davidolrik avatar May 13 '25 13:05 davidolrik

Thanks! I edited my comment from a week ago to avoid confusion.

djmitche avatar May 13 '25 17:05 djmitche

What really got me was that the coefficient was picked up when defining just one tag with urgency.uda.tags.foo.coefficient as the key.

davidolrik avatar May 14 '25 04:05 davidolrik

I can confirm that is the case:

[[email protected] ~]$ task config urgency.uda.tags.foo.coefficient 10
Are you sure you want to add 'urgency.uda.tags.foo.coefficient' with a value of '10'? (yes/no) yes
Config file /home/warrior/.taskrc modified.
[[email protected] ~]$ task add test +foo
Created task 1.
[[email protected] ~]$ task _get 1.urgency
10.8
[[email protected] ~]$ task 1 info

Name          Value                                 
ID            1                                     
Description   test                                  
Status        Pending                               
Entered       2025-05-15 01:52:12 (13s)
Last modified 2025-05-15 01:52:12 (13s)             
Tags          foo
Virtual tags  LATEST PENDING READY TAGGED UNBLOCKED 
UUID          6057d8c5-db8c-4555-b047-fd9d40a2c72f
Urgency       10.8                                  
[tag_foo      x]

    tags            0.8 *    1 =    0.8
    UDA tags.foo      1 *   10 =     10
                                 ------
                                   10.8

This looks to be the case because of two things:

  1. tags.foo is incorrectly allowed to be recognized as an UDA due to the setting urgency.uda.tags.foo.coefficient
  2. it however only works if matched with a single value, once the tags field contains multiple tags (value is foo,bar) it no longer matches foo or bar, hence no "UDA" tag coefficient gets applied

I think the solution here would be to throw a warning when UDA urgency coefficients are attempted to be used with built-in attributes, instead of trying to process them.

tbabej avatar May 15 '25 01:05 tbabej

Definitely had an 'aha' moment in this thread. I thought that the default tags was additive (ie +tag1 and +tag2 = 0.8 * 2, and assumed I had broken something.

Through this post (and revisiting the urgency doc), I realize that using 1+ tag(s) give a score of 0.8 unless they have an explicit coefficient. I have since updated coefficients of tags I've created via my taskrc.

cameronj86 avatar May 16 '25 20:05 cameronj86

Re-opening to solve:

I think the solution here would be to throw a warning when UDA urgency coefficients are attempted to be used with built-in attributes, instead of trying to process them.

djmitche avatar May 18 '25 18:05 djmitche