Skip to content

fix: batch config wiring quick wins (#262-#266)#267

Merged
laynepenney merged 1 commit into
mainfrom
fix/config-wiring-batch
Feb 3, 2026
Merged

fix: batch config wiring quick wins (#262-#266)#267
laynepenney merged 1 commit into
mainfrom
fix/config-wiring-batch

Conversation

@laynepenney
Copy link
Copy Markdown
Member

Summary

Five quick fixes to close gaps left after PR #261's config wiring:

Files changed (6)

File Fixes
codi-rs/src/tui/app.rs #262, #264, #266, #263
codi-rs/src/tui/mod.rs #266
codi-rs/src/main.rs #266, #263
codi-rs/src/agent/types.rs #263, #265
codi-rs/src/agent/mod.rs #263, #265
codi-rs/src/orchestrate/child_agent.rs #263

Test plan

  • cargo build — clean, zero warnings
  • cargo test — 463 tests pass (7 new)
  • New tests: test_dangerous_pattern_match, test_dangerous_pattern_empty, test_dangerous_pattern_invalid_regex_skipped, test_agent_state_default_running_char_count, test_build_system_prompt_from_config_none, test_build_system_prompt_from_config_with_additions, test_app_event_compaction_variant

Review notes

  • maybe_confirm() replaces the old should_confirm() + confirm_tool() two-method pattern to avoid double-serializing tool input JSON
  • Invalid regex patterns in dangerousPatterns config emit a tracing::warn! rather than silently skipping
  • messages_mut() is a known escape hatch that bypasses running_char_count — no current callers, but noted for future awareness

🤖 Generated with Claude Code

Five post-PR-261 fixes to close config wiring gaps:

- Deprecate with_provider/with_provider_and_path bypass constructors (#262)
- Wire on_compaction callback for TUI status feedback (#264)
- Extract build_system_prompt_from_config for -P mode parity (#266)
- Wire dangerousPatterns config through to tool confirmation (#263)
- Cache running_char_count to avoid re-serializing JSON per iteration (#265)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@laynepenney
Copy link
Copy Markdown
Member Author

Self-Review

Build & Tests

  • cargo build — clean, zero warnings
  • cargo test — 463 tests pass (7 new), 0 failures
  • ✅ CI: Type Check pass, Test (macos) pass, Test (ubuntu) pass

Fix-by-fix verification

#262 — Deprecate bypass constructors

  • #[deprecated] attributes on both with_provider() and with_provider_and_path()
  • ✅ Functions remain functional for backwards compat
  • ✅ Deprecation message points to correct pattern

#264 — Wire on_compaction callback

  • Compaction(bool) variant added to AppEvent
  • ✅ Callback wired in set_provider() with Arc + tx.clone() pattern matching other callbacks
  • ✅ Match arm in process_app_events() sets status messages
  • ✅ New test test_app_event_compaction_variant

#266 — Fix -P mode system prompt

  • build_system_prompt_from_config() extracted as standalone public function
  • App::build_system_prompt() delegates to it
  • ✅ Re-exported from tui/mod.rs
  • main.rs handle_prompt() uses build_system_prompt_from_config(Some(config)) instead of hardcoded string
  • ✅ Existing tests still pass, 2 new tests for standalone function

#263 — Wire dangerousPatterns

  • dangerous_patterns: Vec<String> on AgentConfig with Vec::new() default
  • matches_dangerous_pattern() method with tracing::warn! for invalid regex
  • ✅ Unified maybe_confirm() replaces old should_confirm()+confirm_tool() two-method pattern — serializes input once
  • ✅ Wired in build_agent_config() (app.rs), handle_prompt() (main.rs), child_agent.rs
  • ✅ 3 new tests: pattern match, empty patterns, invalid regex graceful skip

#265 — Cache running char count

  • running_char_count: usize on AgentState with 0 default
  • estimate_tokens() uses cached count instead of iterating all messages
  • ✅ Incremented at all 3 message push sites (user msg, assistant msg, tool results)
  • ✅ Recalculated from remaining messages after compact_context() drain
  • ✅ Reset to 0 via AgentState::default() in clear()
  • ✅ 1 new test for default state

Review findings addressed during PR

  • Fixed double serialization: merged should_confirm()+confirm_tool() into single maybe_confirm() method
  • Added tracing::warn! for invalid regex patterns instead of silent skip
  • Noted messages_mut() escape hatch as future-awareness item (no current callers)

No issues found. Ready to merge.

@laynepenney laynepenney merged commit ba5b279 into main Feb 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant