Skip to content

feat(config): Support object-based repository configuration with enabled flag #103

Closed

Description

@integry

Task Description

As part of the effort to improve the repository management UI, the backend data structure for storing monitored repositories needs to be updated. Currently, repos_to_monitor is a simple array of strings. This needs to be changed to an array of objects, where each object contains the repository name and an enabled flag.

This change will allow users to temporarily disable repositories from the UI without removing them from the configuration.

Example of new structure in config.json:

{
  "repos_to_monitor": [
    { "name": "integry/gitfix", "enabled": true },
    { "name": "integry/gitfix-config", "enabled": false }
  ]
}

Implementation Steps

  1. Update configRepoManager.js:

    • Modify the loadMonitoredRepos function to handle the new object-based array. It should filter the array to return only the names of repositories where enabled is true.
    • Update the saveMonitoredRepos function to accept and save the new array of objects structure.
    • Ensure backward compatibility in loadMonitoredRepos. If the loaded data is an array of strings, it should be automatically converted to the new object format with all repositories enabled by default.
  2. Update daemon.js:

    • No significant changes should be needed in daemon.js itself if loadMonitoredRepos correctly returns a simple array of enabled repository names. However, review loadReposFromConfig and getRepos to ensure they handle the output from the updated configRepoManager correctly.
  3. Update packages/dashboard/server.js:

    • The /api/config/repos GET endpoint should be updated to return the full array of repository objects.
    • The /api/config/repos POST endpoint must be updated to handle the incoming array of objects and pass it to saveMonitoredRepos.
  4. Update Validation:

    • Update the validation logic in the POST /api/config/repos endpoint in packages/dashboard/server.js to correctly validate the new array of objects. Each object should have a 'name' (string) and 'enabled' (boolean) property.

Activity

  1. integry commented on Oct 7, 2025

    @integry
    OwnerAuthor

    Implementation Suggestions

    Here are the suggested code modifications for this issue:

    1. src/config/configRepoManager.js

    Update loadMonitoredRepos to handle both the old and new formats and filter by the 'enabled' flag.

    --- a/src/config/configRepoManager.js
    +++ b/src/config/configRepoManager.js
    @@ -48,9 +48,16 @@
             await cloneOrPullConfigRepo();
             
             const config = await fs.readJson(CONFIG_FILE_PATH);
    -        const repos = config.repos_to_monitor || [];
    -        
    -        logger.info({ repos }, 'Successfully loaded monitored repositories');
    +        let reposToMonitor = config.repos_to_monitor || [];
    +
    +        // Handle backward compatibility for old string-based array
    +        if (reposToMonitor.length > 0 && typeof reposToMonitor[0] === 'string') {
    +            reposToMonitor = reposToMonitor.map(repo => ({ name: repo, enabled: true }));
    +        }
    +
    +        const repos = reposToMonitor.filter(repo => repo.enabled).map(repo => repo.name);
    +        
    +        logger.info({ repos_to_monitor: repos, total_configured: reposToMonitor.length }, 'Successfully loaded enabled monitored repositories');
             return repos;
         } catch (error) {
             logger.error({ error: error.message }, 'Failed to load monitored repositories from config');
    @@ -101,7 +108,7 @@
     
             if (!await fs.pathExists(CONFIG_FILE_PATH)) {
                 const initialConfig = {
    -                repos_to_monitor: []
    +                repos_to_monitor: [] // Initialize with the new structure
                 };
     
                 await fs.writeJson(CONFIG_FILE_PATH, initialConfig, { spaces: 2 });
    

    2. packages/dashboard/server.js

    Update the GET and POST handlers for /api/config/repos.

    --- a/packages/dashboard/server.js
    +++ b/packages/dashboard/server.js
    @@ -754,8 +754,12 @@
     
     app.get('/api/config/repos', ensureAuthenticated, async (req, res) => {
       try {
    -    const repos = await configRepoManager.loadMonitoredRepos();
    -    res.json({ repos_to_monitor: repos });
    +    // This needs to load the raw config, not the filtered one
    +    await configRepoManager.cloneOrPullConfigRepo();
    +    const configPath = path.join(process.cwd(), '../.config_repo', 'config.json');
    +    const config = await fs.readJson(configPath);
    +    const repos = config.repos_to_monitor || [];
    +    res.json({ repos_to_monitor: repos });
       } catch (error) {
         console.error('Error in /api/config/repos GET:', error);
         res.status(500).json({ error: 'Failed to load repository configuration' });
    @@ -772,9 +776,12 @@
         if (!Array.isArray(repos_to_monitor)) {
           return res.status(400).json({ error: 'repos_to_monitor must be an array' });
         }
    -    
    +
         for (const repo of repos_to_monitor) {
    -      if (typeof repo !== 'string' || !repo.match(/^[a-zA-Z0-9\-_]+\/[a-zA-Z0-9\-_]+$/)) {
    +      if (typeof repo.name !== 'string' || 
    +          !repo.name.match(/^[a-zA-Z0-9\-_]+\/[a-zA-Z0-9\-_]+$/) ||
    +          typeof repo.enabled !== 'boolean'
    +      ) {
             return res.status(400).json({ error: `Invalid repository format: ${repo}` });
           }
         }
    
  2. propr-dev commented on Oct 7, 2025

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude-sonnet-4-5-20250929 model.

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

    Processing Details:

    • Model: claude-sonnet-4-5-20250929
    • Branch: ai-fix/103-feat-config-support-objec-20251007-1417-claude-sonnet-4-5-20250929-uny
    • Base Branch: main
    • Worktree: issue-103-20251007-1417-claude-sonnet-4-5-20250929-uny
  3. added a commit that references this issue on Oct 7, 2025
  4. added a commit that references this issue on Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions