refactor Config to add Version and migratable#1352
Conversation
yinwm
left a comment
There was a problem hiding this comment.
Code Review
Found 1 issue that should be fixed before merging:
Agents config migration may lose user settings
In pkg/config/config_old.go:612-615:
// Merge agents config if workspace is set
if c.Agents.Defaults.Workspace != "" {
cfg.Agents = c.Agents
}Problem: User's Agents config (e.g., Provider, Model, MaxTokens) is only copied when Workspace is non-empty. If a user configured Model or Provider but didn't set Workspace, their settings will be lost after migration.
Example scenario:
- User has:
{"agents": {"defaults": {"model": "gpt-4o", "provider": "openai"}}} - After migration: Uses default config (user's model/provider settings lost)
Suggested fix:
// Always copy user's Agents config
cfg.Agents = c.Agents
// Ensure Workspace has a default if not set
if cfg.Agents.Defaults.Workspace == "" {
homePath := getHomePath() // or reuse logic from DefaultConfig
cfg.Agents.Defaults.Workspace = filepath.Join(homePath, "workspace")
}Other than this, the PR looks good:
- Config versioning design is correct
- Provider factory simplification is appropriate (old
factory.gologic replaced byfactory_provider.go) - Migration of
Providers→ModelListworks correctly
🤖 Generated with Claude Code
- If this code review was useful, please react with 👍. Otherwise, react with 👎.
|
And, Singleton testing is best done by introducing old and new versions of the configuration file, and doing a real-world scenario test that can also be verified by CI |
add test for this. |
refactor Config to add Version and migratable
📝 Description
Removed usage of the Providers.AuthMethod field
cmd/picoclaw/internal/auth/helpers.go - Removed assignment to Providers..AuthMethod
web/backend/api/oauth.go - Removed synchronization of Providers..AuthMethod
pkg/voice/transcriber_test.go - Remove test cases for Providers.Groq
Configuration versioning migration feature
pkg/config/migration.go - Add loadConfigV0 and loadConfig functions to support automatic migration from legacy configurations
pkg/config/config.go - Modified to support versioned configurations
pkg/config/config_old.go - Added legacy configuration struct
Provider factory simplification
pkg/providers/factory.go - Significantly simplified, removed old provider logic
pkg/providers/factory_test.go - Removed related tests
Translated with DeepL.com (free version)
🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
📚 Technical Context (Skip for Docs)
🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
☑️ Checklist