From 19e98c06d0dd3b6a19a2dc83eea3e327ea44e5ca Mon Sep 17 00:00:00 2001 From: AnnatarHe Date: Wed, 31 Dec 2025 02:47:55 +0800 Subject: [PATCH] fix(model): add backward compatibility for deprecated ccotel config key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support both ccotel (deprecated) and aiCodeOtel config keys to ensure users with existing configs using the old key continue to work after upgrading. The migration happens silently at config read time. - Add deprecated CCOtel field to ShellTimeConfig with old tags - Migrate ccotel to AICodeOtel in ReadConfigFile after unmarshal - Handle deprecated field in mergeConfig for local config overrides 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- model/config.go | 10 ++++++++++ model/types.go | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/model/config.go b/model/config.go index 83ef596..7e1b436 100644 --- a/model/config.go +++ b/model/config.go @@ -154,6 +154,10 @@ func mergeConfig(base, local *ShellTimeConfig) { if local.CCUsage != nil { base.CCUsage = local.CCUsage } + // Migrate deprecated ccotel from local config + if local.CCOtel != nil && local.AICodeOtel == nil { + local.AICodeOtel = local.CCOtel + } if local.AICodeOtel != nil { base.AICodeOtel = local.AICodeOtel } @@ -213,6 +217,12 @@ func (cs *configService) ReadConfigFile(ctx context.Context, opts ...ReadConfigO return } + // Migrate deprecated ccotel field to AICodeOtel (silent migration) + if config.CCOtel != nil && config.AICodeOtel == nil { + config.AICodeOtel = config.CCOtel + config.CCOtel = nil + } + // Read and merge local config if exists if files.localFile != "" { if localConfig, localErr := os.ReadFile(files.localFile); localErr == nil { diff --git a/model/types.go b/model/types.go index 4421f5e..a2e3ed9 100644 --- a/model/types.go +++ b/model/types.go @@ -81,6 +81,10 @@ type ShellTimeConfig struct { // CCUsage configuration for Claude Code usage tracking (v1 - ccusage CLI based) CCUsage *CCUsage `toml:"ccusage" yaml:"ccusage" json:"ccusage"` + // CCOtel is deprecated, use AICodeOtel instead + // Deprecated: This field will be removed in a future version + CCOtel *AICodeOtel `toml:"ccotel" yaml:"ccotel" json:"ccotel"` + // AICodeOtel configuration for OTEL-based AI CLI tracking (Claude Code, Codex, etc.) AICodeOtel *AICodeOtel `toml:"aiCodeOtel" yaml:"aiCodeOtel" json:"aiCodeOtel"` @@ -118,6 +122,7 @@ var DefaultConfig = ShellTimeConfig{ AI: DefaultAIConfig, Exclude: []string{}, CCUsage: nil, + CCOtel: nil, // deprecated AICodeOtel: nil, CodeTracking: nil, LogCleanup: nil,