Skip to content

Fix local config settings: incorrect behavior when clearing individual values #193

@github-actions

Description

@github-actions

Local config settings issues investigation report

Problem Description

Investigating issue #191 about local config settings not working properly. The specific questions were:

  1. Where are local config settings saved to?
  2. Why can't individual values be cleared?

Findings

Where local config settings are saved to

  • Global config: Stored in ~/.mycoder/config.json
  • Project config: Stored in .mycoder/config.json in the project directory

The system correctly creates these files when settings are modified. However, there's no explicit indication to users about where these files are located.

Issues with clearing individual config values

I've identified a critical bug in the configuration system. When a user attempts to clear an individual configuration key using mycoder config clear <key>, the system behaves incorrectly:

  1. Instead of removing just the specified key from the config file, it copies the entire merged configuration (from all levels) into the target config file.
  2. This effectively overrides all configuration settings at that level with the current merged values, rather than just removing the specified key.

Steps to reproduce:

  1. Set a project-level config: mycoder config set temperature 0.5
  2. Check the project config file: Contains only {"temperature": 0.5}
  3. Try to clear that value: mycoder config clear temperature
  4. Check the project config file again: Now contains ALL configuration values from all levels

Code issue:
The problem is in the config.ts file in the config clear command handler (around line 280-320). When clearing a specific key, it:

  1. Gets the current merged config from all levels
  2. Creates a new object without the specified key
  3. Calls updateConfig(newConfig) with the entire object
  4. This replaces the entire config file instead of just removing the key

This behavior contradicts the expected functionality of the clearConfigKey function defined in settings/config.ts which should be used but isn't.

Additional Issues

  1. Global flag issues: The --global flag doesn't seem to be properly defined in the command options.
  2. Confusing feedback: When clearing a key, the system reports "Cleared at level, now using: (from project config)" even when the key wasn't actually removed from the config file.

Recommended Fixes

  1. Fix the clear command: Modify the config.ts command handler to use the clearConfigKey function when clearing individual keys.
  2. Add global flag: Ensure the --global flag is properly defined in the command options.
  3. Improve documentation: Add clear documentation about where config files are stored.
  4. Add verbose output option: Allow users to see the exact file paths being used.

Technical Implementation Plan

  1. Update the config.ts command handler to use clearConfigKey instead of manually creating a new object and calling updateConfig.
  2. Add the global flag to the command options if it's missing.
  3. Enhance the config list command to show which level each setting is coming from.
  4. Add a verbose mode that shows the file paths being used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions