Skip to content

Add useSystemReadiness hook for onboarding state #892

Closed

Description

@propr-dev

Context

We need to track whether the user has completed the initial setup (adding an AI agent and monitoring a repository) so we can display targeted onboarding guidance.

Requirements

  • Create a custom React hook useSystemReadiness that checks for configured agents and repositories.
  • It should fetch data from getAgents and getRepoConfig APIs.
  • Return an object with hasAgents, hasRepos, isLoading, and error state.

Implementation Specification

  • Create a new file propr-ui/src/hooks/useSystemReadiness.ts containing the custom hook.
  • Handle loading states appropriately to prevent UI flashing before the API calls complete.

Acceptance Criteria

  • The hook successfully fetches data from both APIs.
  • It correctly evaluates whether at least one enabled agent and one repository exist.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Mar 3, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    Creating a centralized hook for system readiness allows any component (Dashboard, Layout Sidebar) to react to the user's onboarding progress without duplicating API calls or logic. We use Promise.all for efficiency.

    File: propr-ui/src/hooks/useSystemReadiness.ts

    import { useState, useEffect } from 'react';
    import { getAgents, getRepoConfig, AgentConfig } from '../api/proprApi';
    
    export interface SystemReadiness {
      hasAgents: boolean;
      hasRepos: boolean;
      isLoading: boolean;
      error: string | null;
    }
    
    export function useSystemReadiness(): SystemReadiness {
      const [readiness, setReadiness] = useState<SystemReadiness>({
        hasAgents: false,
        hasRepos: false,
        isLoading: true,
        error: null
      });
    
      useEffect(() => {
        let isMounted = true;
    
        const checkSystem = async () => {
          try {
            // Fetch agent and repo configurations in parallel to minimize load time
            const [agentsData, repoData] = await Promise.all([
              getAgents(),
              getRepoConfig()
            ]);
    
            if (!isMounted) return;
    
            // Check if there is at least one enabled agent
            const enabledAgents = (agentsData.agents || []).filter((a: AgentConfig) => a.enabled);
            
            // Extract and validate repository configuration
            // Handle both legacy string array formats and newer object array formats
            const repos = (repoData as any).repos_to_monitor || [];
            const enabledRepos = repos.filter((r: any) => {
               if (typeof r === 'string') return true;
               if (r && typeof r === 'object') return r.enabled !== false;
               return false;
            });
    
            setReadiness({
              hasAgents: enabledAgents.length > 0,
              hasRepos: enabledRepos.length > 0,
              isLoading: false,
              error: null
            });
          } catch (err) {
            if (isMounted) {
              setReadiness(prev => ({ 
                ...prev, 
                isLoading: false, 
                error: (err as Error).message 
              }));
            }
          }
        };
    
        checkSystem();
    
        return () => {
          isMounted = false;
        };
      }, []);
    
      return readiness;
    }
  2. propr-dev commented on Mar 3, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using claude agent with claude-opus-4-5-20251101 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-4-5-20251101
    • Branch: 892/claude-opus-4-5-20251101-add-usesystemreadiness-ho-20260303-1203-iox
    • Base Branch: 892-epic-create-usesystemreadiness-xcn
    • Worktree: issue-892-20260303-1203-claude-opus-4-5-20251101-iox

    🔍 Track Task Execution

  3. added a commit that references this issue on Mar 3, 2026
  4. added a commit that references this issue on Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions