@@ -7,6 +7,7 @@ import React, { useCallback, useEffect, useState } from 'react';
77import { render } from 'react-dom' ;
88import { ChatInput } from './components/ChatInput' ;
99import { EmptyState } from './components/EmptyState' ;
10+ import { FilterButton , FilterState } from './components/FilterButton' ;
1011import { GlobalSessionItem } from './components/GlobalSessionItem' ;
1112import { IssueItem } from './components/IssueItem' ;
1213import { LoadingState } from './components/LoadingState' ;
@@ -38,6 +39,7 @@ function Dashboard() {
3839 const [ refreshing , setRefreshing ] = useState ( false ) ;
3940 const [ issueSort , setIssueSort ] = useState < 'date-oldest' | 'date-newest' > ( 'date-oldest' ) ;
4041 const [ hoveredIssue , setHoveredIssue ] = useState < IssueData | null > ( null ) ;
42+ const [ globalFilter , setGlobalFilter ] = useState < FilterState > ( { showTasks : true , showProjects : true } ) ;
4143
4244 useEffect ( ( ) => {
4345 // Listen for messages from the extension
@@ -150,15 +152,19 @@ function Dashboard() {
150152 const mixedItems = isGlobal ? ( ( ) => {
151153 const mixed : Array < { type : 'session' , data : SessionData , index : number } | { type : 'project' , data : ProjectData } > = [ ] ;
152154
153- // Add sessions
154- activeSessions . forEach ( ( session , index ) => {
155- mixed . push ( { type : 'session' , data : session , index } ) ;
156- } ) ;
155+ // Add sessions based on filter
156+ if ( globalFilter . showTasks ) {
157+ activeSessions . forEach ( ( session , index ) => {
158+ mixed . push ( { type : 'session' , data : session , index } ) ;
159+ } ) ;
160+ }
157161
158- // Add projects
159- recentProjects . forEach ( ( project : ProjectData ) => {
160- mixed . push ( { type : 'project' , data : project } ) ;
161- } ) ;
162+ // Add projects based on filter
163+ if ( globalFilter . showProjects ) {
164+ recentProjects . forEach ( ( project : ProjectData ) => {
165+ mixed . push ( { type : 'project' , data : project } ) ;
166+ } ) ;
167+ }
162168
163169 function shuffle < T > ( array : T [ ] ) : T [ ] {
164170 for ( let i = array . length - 1 ; i > 0 ; i -- ) {
@@ -258,7 +264,15 @@ function Dashboard() {
258264
259265 { /* Tasks Area */ }
260266 < div className = "tasks-area" >
261- < h2 className = "area-header" > { isGlobal ? 'Continue working on...' : 'Active tasks' } </ h2 >
267+ < div className = "area-header-container" >
268+ < h2 className = "area-header" > { isGlobal ? 'Continue working on...' : 'Active tasks' } </ h2 >
269+ { isGlobal && (
270+ < FilterButton
271+ filterState = { globalFilter }
272+ onFilterChange = { setGlobalFilter }
273+ />
274+ ) }
275+ </ div >
262276 { dashboardState ?. state === 'ready' && (
263277 < div className = "section-count" >
264278 { activeSessions . length || 0 } task{ activeSessions . length !== 1 ? 's' : '' }
0 commit comments