Skip to content

refactor: extract duplicated utilities into shared modules#4

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782257427-refactor-shared-utilities
Open

refactor: extract duplicated utilities into shared modules#4
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782257427-refactor-shared-utilities

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Extracts duplicated utility functions scattered across 11 source files into three new shared modules in codex-plus-core:

toml_helpers — TOML document parsing and manipulation:

  • parse_toml_document(contents) -> Result<DocumentMut> (was in relay_config, settings, computer_use_guard)
  • table_mut_or_insert(doc, key) -> Result<&mut Table> (was in relay_config, computer_use_guard)
  • ensure_trailing_newline(contents) -> String (was in relay_config, computer_use_guard)
  • normalize_trimmed_text(contents) -> String (was normalize_text_toml in relay_config, normalize_text_config in settings)
  • unquote_toml_string / unquote_toml_string_simple (was in model_catalog, relay_config with different implementations)

json_value — JSON Value field extraction:

  • json_string_value(Option<&Value>) -> String (was string_value in zed_remote, zed_remote/fallback, zed_remote/registry)
  • required_json_string(&Value, key) -> Option<String> (was required_string in script_market)
  • optional_json_string(&Value, key) -> String (was optional_string in script_market)

timestamp — Timestamp utilities:

  • timestamp_millis() -> u128 (was in relay_config, env_conflicts)
  • timestamp_secs_string() -> String (was current_unix_timestamp_string in user_scripts)

Net result: -40 lines (149 added, 189 removed). All existing tests pass; the one pre-existing failure (settings_store_save_load_roundtrip_preserves_aggregate_relay_settings) also fails on main.

Link to Devin session: https://app.devin.ai/sessions/88fdd12ce3cc41179b2d34e6e5d1fef6
Requested by: @ManhND226677

Extract duplicated code patterns into three new shared modules in
codex-plus-core:

- toml_helpers: parse_toml_document, table_mut_or_insert,
  ensure_trailing_newline, normalize_trimmed_text,
  unquote_toml_string, unquote_toml_string_simple
- json_value: json_string_value, required_json_string,
  optional_json_string
- timestamp: timestamp_millis, timestamp_secs_string

Deduplicated across 11 source files:
- relay_config.rs, computer_use_guard.rs, settings.rs (TOML helpers)
- zed_remote.rs, zed_remote/fallback.rs, zed_remote/registry.rs (JSON)
- model_catalog.rs, script_market.rs (mixed)
- env_conflicts.rs, user_scripts.rs (timestamp)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@ManhND226677 ManhND226677 self-assigned this Jun 23, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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