@@ -8,7 +8,7 @@ import { computed, onMounted, provide, ref, shallowRef, watch } from 'vue'
88import { useRoute , useRouter } from ' #app/composables/router'
99import TaskDetails from ' ../components/TaskDetails.vue'
1010import TaskGraphView from ' ../components/TaskGraphView.vue'
11- import TaskId from ' ../components/TaskId .vue'
11+ import TaskNameFilter from ' ../components/TaskNameFilter .vue'
1212import { useRpc } from ' ../composables/rpc'
1313import { getTaskPackageKey , isTaskInGraphKey } from ' ../utils/task-plan'
1414
@@ -25,18 +25,18 @@ const planLoading = ref(false)
2525const graphError = ref (' ' )
2626const planError = ref (' ' )
2727const unsupportedVersion = ref (false )
28- const filters = ref <{ search: string , selected: string [] | null }>({ search: ' ' , selected: null })
28+ const filters = ref ({ search: ' ' })
29+ const excludedNames = ref <string []>([])
2930const isolatedTasksVisible = ref (false )
3031const taskEntries = computed (() => Object .entries (graph .value ?.tasks || {}))
31- // DataSearchPanel requires icon and always renders its element; hidden removes the empty flex slot.
32- const taskRules = computed (() => [... new Set (taskEntries .value .map (([, task ]) => task .name ))].sort ().map (name => ({ name , match: / . * / , icon: ' hidden' })))
32+ const taskNames = computed (() => [... new Set (taskEntries .value .map (([, task ]) => task .name ))].sort ())
3333const matchedTasks = computed (() => taskEntries .value .filter (([id , task ]) =>
34- ( ! filters .value .selected || filters . value . selected . includes (task .name ) )
34+ ! excludedNames .value .includes (task .name )
3535 && ` ${id } ${graph .value ?.packages [task .package ]?.name || ' ' } ` .toLowerCase ().includes (filters .value .search .toLowerCase ()),
3636))
3737const matchedIds = computed (() => new Set (matchedTasks .value .map (([id ]) => id )))
3838const connectedTaskIds = computed (() => new Set (taskEntries .value .flatMap (([id , task ]) => task .dependsOn ?.length ? [id , ... task .dependsOn ] : [])))
39- const isolatedCount = computed (() => taskEntries .value .filter (([id ]) => ! connectedTaskIds .value .has (id )).length )
39+ const isolatedCount = computed (() => matchedTasks .value .filter (([id ]) => ! connectedTaskIds .value .has (id )).length )
4040const visibleGraph = computed <TaskGraph | undefined >((previous ) => {
4141 if (! graph .value )
4242 return undefined
@@ -71,7 +71,34 @@ const visibleGraph = computed<TaskGraph | undefined>((previous) => {
7171})
7272const intermediateTaskCount = computed (() => Object .keys (visibleGraph .value ?.tasks || {}).filter (id => ! matchedIds .value .has (id )).length )
7373const view = ref <' list' | ' graph' >(' list' )
74- const sortedTasks = computed (() => [... matchedTasks .value ].sort (([, a ], [, b ]) => a .package .localeCompare (b .package ) || a .name .localeCompare (b .name )))
74+ const packageGroups = computed (() => {
75+ const groups = new Map <string , typeof matchedTasks .value >()
76+ for (const entry of matchedTasks .value ) {
77+ const path = entry [1 ].package
78+ const tasks = groups .get (path )
79+ if (tasks )
80+ tasks .push (entry )
81+ else
82+ groups .set (path , [entry ])
83+ }
84+ return [... groups ].sort (([a ], [b ]) => a .localeCompare (b )).map (([path , tasks ]) => ({
85+ path ,
86+ label: path === ' .' ? ' Workspace root' : graph .value ?.packages [path ]?.name || path ,
87+ tasks: tasks .sort (([, a ], [, b ]) => a .name .localeCompare (b .name )),
88+ }))
89+ })
90+ const collapsedPackages = ref (new Set <string >())
91+ const collapsedSearchResults = ref (new Set <string >())
92+ watch (() => filters .value .search , () => collapsedSearchResults .value .clear ())
93+ const collapsed = computed (() => filters .value .search ? collapsedSearchResults .value : collapsedPackages .value )
94+
95+ function togglePackage(path : string ) {
96+ if (collapsed .value .has (path ))
97+ collapsed .value .delete (path )
98+ else
99+ collapsed .value .add (path )
100+ }
101+
75102let planRequestVersion = 0
76103
77104async function loadPlan(id : string ) {
@@ -115,6 +142,7 @@ async function refresh() {
115142 if (result === ' unsupported-version' )
116143 return
117144 graph .value = result
145+ excludedNames .value = excludedNames .value .filter (name => taskNames .value .includes (name ))
118146 if (selected .value && graph .value .tasks [selected .value ])
119147 await loadPlan (selected .value )
120148 else
@@ -168,9 +196,10 @@ onMounted(refresh)
168196 </div >
169197 <div v-else class =" text-sm relative" :class =" view === 'graph' ? 'h-full flex flex-col max-h-screen of-hidden' : ''" >
170198 <div class =" z-panel-nav p4" :class =" view === 'list' ? 'sticky left-4 right-4 top-4' : 'shrink-0'" >
171- <DataSearchPanel v-model =" filters " :rules =" taskRules " >
199+ <DataSearchPanel v-model =" filters " :rules =" [] " >
172200 <template #search-end >
173- <div class =" h10 mr2 flex items-center" >
201+ <div class =" h10 mr2 flex items-center gap2" >
202+ <TaskNameFilter v-model :excluded =" excludedNames " :names =" taskNames " />
174203 <DisplayIconButton v-tooltip =" ' Refresh tasks' " title="Refresh tasks" :class-icon =" graphLoading ? ' i-ph-arrow-clockwise-duotone animate-spin' : ' i-ph-arrow-clockwise-duotone' " :disabled =" graphLoading " @click =" refresh " />
175204 </div >
176205 </template >
@@ -194,14 +223,21 @@ onMounted(refresh)
194223 </div >
195224 <VisualLoading v-if =" graphLoading && ! graph " text="Loading tasks…" />
196225 <section v-else-if =" graph && view === 'list'" class =" p4 pb16" aria-label =" Tasks" >
197- <div v-for =" [id, task] in sortedTasks" :key =" id" class =" flex pb2" >
198- <button class =" hover:bg-active flex items-center gap2 px2 py1 w-full border border-base rounded text-left" :class =" selected === id ? 'bg-active' : ''" :title =" id" :aria-pressed =" selected === id" :disabled =" graphLoading" @click =" selectTask(id)" >
199- <span class =" i-ph-terminal-window-duotone op-fade shrink-0" />
200- <TaskId :id =" id " class="truncate" />
201- <span v-if =" task.dependsOn?.length" v-tooltip =" `Depends on ${task.dependsOn.length} ${task.dependsOn.length === 1 ? 'task' : 'tasks'}`" class =" ml-auto text-xs op-fade flex items-center gap1" ><span class =" i-ph-graph-duotone" />{{ task.dependsOn.length }}</span >
202- </button >
203- </div >
204- <div v-if =" !sortedTasks.length" class =" w-full h-48 flex items-center justify-center text-sm op50 italic" >
226+ <details v-for =" group in packageGroups" :key =" group.path" :open =" !collapsed.has(group.path)" class =" mb2" >
227+ <summary class =" cursor-default select-none flex gap-1 items-center px1 py1 rounded hover:bg-active" :title =" group.path" @click.prevent =" togglePackage(group.path)" >
228+ <span class =" i-ph-caret-right-duotone transition op50" :class =" { 'rotate-90': !collapsed.has(group.path) }" />
229+ <span class =" op70 text-sm" >{{ group.label }}</span >
230+ <span class =" op40 text-xs font-mono" >{{ group.tasks.length }}</span >
231+ </summary >
232+ <div class =" flex flex-col gap2 pl4 pt2" >
233+ <button v-for =" [id, task] in group.tasks" :key =" id" class =" hover:bg-active flex items-center gap2 px2 py1 w-full border border-base rounded text-left" :class =" selected === id ? 'bg-active' : ''" :title =" id" :aria-pressed =" selected === id" :disabled =" graphLoading" @click =" selectTask(id)" >
234+ <span class =" i-ph-terminal-window-duotone op-fade shrink-0" />
235+ <span class =" font-mono truncate" >{{ task.name }}</span >
236+ <span v-if =" task.dependsOn?.length" v-tooltip =" `Depends on ${task.dependsOn.length} ${task.dependsOn.length === 1 ? 'task' : 'tasks'}`" class =" ml-auto text-xs op-fade flex items-center gap1" ><span class =" i-ph-graph-duotone" />{{ task.dependsOn.length }}</span >
237+ </button >
238+ </div >
239+ </details >
240+ <div v-if =" !packageGroups.length" class =" w-full h-48 flex items-center justify-center text-sm op50 italic" >
205241 <p >No tasks</p >
206242 </div >
207243 </section >
0 commit comments