refactor: Reduce sub-field render boilerplate#108
Open
zfsguy wants to merge 1 commit intostephenleo:mainfrom
Open
refactor: Reduce sub-field render boilerplate#108zfsguy wants to merge 1 commit intostephenleo:mainfrom
zfsguy wants to merge 1 commit intostephenleo:mainfrom
Conversation
Owner
|
@zfsguy can you please resolve the formatting CI failure from here: https://github.com/stephenleo/cship/actions/runs/23119102465/job/67521191716?pr=108 you'll also need to merge in latest main to solve the conflict |
stephenleo
added a commit
that referenced
this pull request
Mar 27, 2026
…sed HasThresholdStyle impls - Merged CostSubfieldConfig and ContextWindowSubfieldConfig into a unified SubfieldConfig struct with #[cfg(test)] type aliases for backward compat. - Added HasThresholdStyle trait and impl_has_threshold_style! macro to config.rs; only ContextWindowConfig gets an impl (the three unused CostConfig, ContextBarConfig, UsageLimitsConfig impls are intentionally absent per Story 3.1). - Added render_styled_value() to format.rs with six unit tests covering all paths (format, threshold, invert_threshold, parent fallback, no-sub/no-parent). - Replaced all inline threshold/style boilerplate in cost.rs (5 functions) and context_window.rs (8 functions) with render_styled_value() calls. - cargo build, cargo test (65/65), and cargo clippy -- -D warnings all exit 0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5 tasks
stephenleo
added a commit
that referenced
this pull request
Mar 27, 2026
…sed HasThresholdStyle impls - Merged CostSubfieldConfig and ContextWindowSubfieldConfig into a unified SubfieldConfig struct with #[cfg(test)] type aliases for backward compat. - Added HasThresholdStyle trait and impl_has_threshold_style! macro to config.rs; only ContextWindowConfig gets an impl (the three unused CostConfig, ContextBarConfig, UsageLimitsConfig impls are intentionally absent per Story 3.1). - Added render_styled_value() to format.rs with six unit tests covering all paths (format, threshold, invert_threshold, parent fallback, no-sub/no-parent). - Replaced all inline threshold/style boilerplate in cost.rs (5 functions) and context_window.rs (8 functions) with render_styled_value() calls. - cargo build, cargo test (65/65), and cargo clippy -- -D warnings all exit 0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CostSubfieldConfigandContextWindowSubfieldConfigwith a singleSubfieldConfigtypeHasThresholdStyletrait for uniform access to style/threshold fields across parent configsrender_styled_value()helper informat.rsthat centralizes the style/threshold/format rendering pipelinecontext_window.rsandcost.rsto use the new helper, reducing each from ~40-60 lines to ~15 linesFiles changed
src/config.rsSubfieldConfig,HasThresholdStyletrait with macrosrc/format.rsrender_styled_value()with 6 unit testssrc/modules/context_window.rssrc/modules/cost.rsTest plan
cargo testpasses (291 unit + 65 integration)cargo clippycleancargo build --releaseclean