@@ -18,6 +18,7 @@ export function useRBAC() {
1818 max_watchlist_stocks ?: number ;
1919 max_rebalance_stocks ?: number ;
2020 max_scheduled_rebalances ?: number ;
21+ max_debate_rounds ?: number ;
2122 schedule_resolution ?: string ;
2223 optimization_mode ?: string ;
2324 number_of_search_sources ?: number ;
@@ -97,6 +98,7 @@ export function useRBAC() {
9798 const maxWatchlistStocks = limits ?. max_watchlist_stocks !== undefined ? Number ( limits . max_watchlist_stocks ) : undefined ;
9899 const maxRebalanceStocks = limits ?. max_rebalance_stocks !== undefined ? Number ( limits . max_rebalance_stocks ) : undefined ;
99100 const maxScheduledRebalances = limits ?. max_scheduled_rebalances !== undefined ? Number ( limits . max_scheduled_rebalances ) : undefined ;
101+ const maxDebateRounds = limits ?. max_debate_rounds !== undefined ? Number ( limits . max_debate_rounds ) : undefined ;
100102 const scheduleResolution = limits ?. schedule_resolution || undefined ;
101103 const optimizationMode = limits ?. optimization_mode || undefined ;
102104 const numberOfSearchSources = limits ?. number_of_search_sources !== undefined ? Number ( limits . number_of_search_sources ) : undefined ;
@@ -119,6 +121,7 @@ export function useRBAC() {
119121 max_watchlist_stocks : maxWatchlistStocks ,
120122 max_rebalance_stocks : maxRebalanceStocks ,
121123 max_scheduled_rebalances : maxScheduledRebalances ,
124+ max_debate_rounds : maxDebateRounds ,
122125 schedule_resolution : scheduleResolution ,
123126 optimization_mode : optimizationMode ,
124127 number_of_search_sources : numberOfSearchSources ,
@@ -355,6 +358,22 @@ export function useRBAC() {
355358 return foundLimit ? maxLimit : 2 ; // Default fallback
356359 } ;
357360
361+ const getMaxDebateRounds = ( ) : number => {
362+ // Get the highest debate rounds limit from all user roles
363+ let maxLimit = 0 ;
364+ let foundLimit = false ;
365+
366+ for ( const userRole of userRoles ) {
367+ const roleDetail = roleDetails . get ( userRole . role_id ) ;
368+ if ( roleDetail && typeof roleDetail . max_debate_rounds === 'number' ) {
369+ maxLimit = Math . max ( maxLimit , roleDetail . max_debate_rounds ) ;
370+ foundLimit = true ;
371+ }
372+ }
373+
374+ return foundLimit ? maxLimit : 2 ; // Default to 2 debate rounds
375+ } ;
376+
358377 const getScheduleResolution = ( ) : string [ ] => {
359378 // Don't hardcode for admin - use database values
360379 // Collect all available resolutions from all user roles
@@ -516,6 +535,7 @@ export function useRBAC() {
516535 getMaxWatchlistStocks,
517536 getMaxRebalanceStocks,
518537 getMaxScheduledRebalances,
538+ getMaxDebateRounds,
519539 getScheduleResolution,
520540 getMaxSearchSources,
521541 getAvailableOptimizationModes,
0 commit comments