# Feature request - cylc tui filter by task state

**URL:** <https://cylc.discourse.group/t/feature-request-cylc-tui-filter-by-task-state/846>\
**Category:** Cylc Development\
**Created:** [January 6, 2024, 10:44pm UTC](https://cylc.discourse.group/t/feature-request-cylc-tui-filter-by-task-state/846 "2024-01-06T22:44:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonnyhtw](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jonnyhtw/32/232_2.png) [@jonnyhtw](https://cylc.discourse.group/u/jonnyhtw)\
**Post date:** [January 6, 2024, 10:44pm UTC](https://cylc.discourse.group/t/feature-request-cylc-tui-filter-by-task-state/846/1 "2024-01-06T22:44:07Z")

</div>

hi there,

just wondering if would it be possible to filter by task state in a future version of `cylc tui`? the current view shows a lot of (to me) redundant tasks which are in a ‘waiting’ state.

cheers,

![image](https://global.discourse-cdn.com/free1/uploads/cylc1/original/1X/9244d0ebe20c79e27598afaa0fee6f59f7c2154f.png)

---

<div class="post-metadata">

**Author:** ![hilary.j.oliver](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/hilary.j.oliver/32/4_2.png) [@hilary.j.oliver](https://cylc.discourse.group/u/hilary.j.oliver)\
**Post date:** [January 6, 2024, 11:47pm UTC](https://cylc.discourse.group/t/feature-request-cylc-tui-filter-by-task-state/846/2 "2024-01-06T23:47:30Z")

</div>

Those “redundant” waiting tasks are what comes next in the graph, downstream of current running tasks.

Good news on the feature request - just hit `F` for “filter” and check off the states you want to see. (Hit `h` for the help screen, to see all the capabilities).

 ![tui-sshot](https://global.discourse-cdn.com/free1/uploads/cylc1/original/1X/4f7861514ee791d91fe9325cb772e84233948384.png)

---

<div class="post-metadata">

**Author:** ![jonnyhtw](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jonnyhtw/32/232_2.png) [@jonnyhtw](https://cylc.discourse.group/u/jonnyhtw)\
**Post date:** [January 8, 2024, 12:47am UTC](https://cylc.discourse.group/t/feature-request-cylc-tui-filter-by-task-state/846/3 "2024-01-08T00:47:16Z")

</div>

> Those “redundant” waiting tasks are what comes next in the graph, downstream of current running tasks.

ah yeah i just meant _i don’t want to see them_ rather then _redundant i guess haha_

> Good news on the feature request…

oh awesome, thanks

---

<div class="post-metadata">

**Author:** ![oliver.sanders](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/oliver.sanders/32/110_2.png) [@oliver.sanders](https://cylc.discourse.group/u/oliver.sanders)\
**Post date:** [January 8, 2024, 9:49am UTC](https://cylc.discourse.group/t/feature-request-cylc-tui-filter-by-task-state/846/4 "2024-01-08T09:49:59Z")

</div>

The functionality is there (F key as Hillary mentioned), but unfortunately there is an unresolved issue with task filtering at the moment.

> <https://github.com/cylc/cylc-flow/issues/5716>
>
> Sometimes, when you filter by task state in Tui, you don't see complete results.…
> 
> It would appear that this is caused by missing "root" families in the data store, demonstrated by this diff:
> 
> \`\`\`diff
> diff --git a/cylc/flow/network/resolvers.py b/cylc/flow/network/resolvers.py
> index b6effe143..319851e75 100644
> \--- a/cylc/flow/network/resolvers.py
> +++ b/cylc/flow/network/resolvers.py
> @@ -183,7 +183,10 @@ def get\_state\_from\_selectors(tokens):
>  
> def node\_ids\_filter(tokens, state, items) -\> bool:
> """Match id arguments with node attributes."""
> \- return any(
> + print()
> + for item in items:
> + print(tokens, item)
> + ret = any(
> (
> # don't match an empty string (globs should be implicit)
> not item.is\_null
> @@ -195,6 +198,7 @@ def node\_ids\_filter(tokens, state, items) -\> bool:
> # match namespace name
> and (
> not item\['task'\]
> + # or item\['task'\] == 'root'
> or fnmatchcase(tokens\['task'\], item\['task'\])
> )
> # match job
> @@ -213,6 +217,8 @@ def node\_ids\_filter(tokens, state, items) -\> bool:
> )
> for item in uniq(items)
> )
> + print('$$$', ret)
> + return ret
>  
>  
> def node\_filter(node, node\_type, args, state):
> @@ -239,6 +245,7 @@ def node\_filter(node, node\_type, args, state):
> else:
> # live objects can be represented by a universal ID
> tokens = Tokens(node.id)
> +
> return (
> (
> (
> 
> \`\`\`
> 
> Which when run against this query:
> 
> \`\`\`graphql
> query($taskStates:\[String\]) {
> workflows(ids:\["\*"\]) {
> test1: familyProxies(ids: \["\*"\], states: $taskStates) {
> id
> state
> }
> }
> }
> \`\`\`
> 
> Produces this result:
> 
> \`\`\`json
> {
> "data": {
> "workflows": \[
> {
> "test1": \[
> {
> "id": "~osanders/generic/run1//20191218T1200Z/BAR",
> "state": "succeeded"
> }
> \]
> }
> \]
> }
> }
> \`\`\`
> 
> With this stdout:
> 
> \`\`\`
> ~osanders/generic/run1//20191218T1200Z/BAR //\*
> $$$ True
> \`\`\`
> 
> Note only the \`BAR\` family appears, no \`root\` family.
> 
> So either the \`root\` families aren't in the data store OR aren't being called up for filtering? Dunno.
> 
> Workflow definition:
> 
> \`\`\`ini
> {
> "data": {
> "workflows": \[
> {
> "test1": \[
> {
> "id": "~osanders/generic/run1//20191218T1200Z/BAR",
> "state": "succeeded"
> }
> \]
> }
> \]
> }
> }
> \`\`\`
> 
> Workflow state:
> 
> !\[Screenshot from 2023-09-04 17-25-48\](https://github.com/cylc/cylc-flow/assets/16705946/e4400d66-0d4f-4b7e-af71-b03a24e21495)
> 
> So either the \`root\` f

---

<div class="post-metadata">

**Author:** ![jonnyhtw](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jonnyhtw/32/232_2.png) [@jonnyhtw](https://cylc.discourse.group/u/jonnyhtw)\
**Post date:** [January 9, 2024, 12:35am UTC](https://cylc.discourse.group/t/feature-request-cylc-tui-filter-by-task-state/846/5 "2024-01-09T00:35:50Z")

</div>

OK thanks a lot @oliver.sanders 🙂
