🤖 refactor: auto-cleanup#3662
Merged
Merged
Conversation
Contributor
Author
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
e56f60c to
c5b64f9
Compare
Contributor
Author
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
c5b64f9 to
7ce9a2a
Compare
bashMonitorWakeStore and backgroundProcessManager each inlined an identical ANSI_ESCAPE_PATTERN regex plus the same strip-ANSI + drop-control-chars expression. Single-source both in src/node/utils/ansi.ts so the escape pattern can't drift between the two terminal-output sanitizers. Behavior-preserving.
InstructionsTab.tsx defined a local formatBytes that was byte-for-byte identical (only the parameter name differed) to the shared formatBytes in @/common/utils/formatBytes. Import the shared helper instead of maintaining a second copy. Behavior-preserving.
anthropicSupportsNativeXhigh (src/common/types/thinking.ts) and getExplicitThinkingPolicy (src/common/utils/thinking/policy.ts) each inlined the identical trim -> lowercase -> strip 'provider:' -> strip 'namespace/' chain to derive the bare model id. Extract it into a shared stripModelProviderPrefixes helper and reuse it in both. Behavior-preserving: the helper runs the same two .replace() calls in the same order.
Contributor
Author
|
@codex review New cleanup on this run: extracted the duplicated model-string normalization chain ( |
|
To use Codex here, create a Codex account and connect to github. |
ThomasK33
approved these changes
Jul 1, 2026
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
This is the long-lived auto-cleanup PR. Each run, the auto-cleanup agent reviews new commits merged to
main, rebases onto the latestmain, and applies at most one extremely low-risk, behavior-preserving cleanup. The branch accumulates a small stack of independent cleanups until it is merged.This run extracts the duplicated model-string normalization chain (
trim→toLowerCase→ stripprovider:prefix → stripnamespace/segment) thatanthropicSupportsNativeXhigh(src/common/types/thinking.ts) andgetExplicitThinkingPolicy(src/common/utils/thinking/policy.ts) each inlined verbatim into a sharedstripModelProviderPrefixeshelper. This area was just touched by #3664 (Claude Sonnet 5), which relies onanthropicSupportsNativeXhighfor capability detection. Behavior-preserving.Included cleanups (diff vs
main)refactor: extract shared stripAnsiControlChars helper—src/node/services/bashMonitorWakeStore.tsandsrc/node/services/backgroundProcessManager.tseach defined a byte-for-byte identicalANSI_ESCAPE_PATTERNregex and inlined the same strip-ANSI + drop-control-chars expression (sanitizeBashMonitorWakeLine/sanitizeMonitorLine). Both now import the newstripAnsiControlCharsfromsrc/node/utils/ansi.ts.refactor: dedupe InstructionsTab formatBytes into shared helper—src/browser/components/InstructionsTab/InstructionsTab.tsxdefined a localformatBytes(n)that was byte-for-byte identical (only the parameter name differed) to the already-sharedformatBytesinsrc/common/utils/formatBytes.ts(used byFileReadToolCall,WebFetchToolCall,AttachFileToolCall,AgentSkillReadFileToolCall, and the CLI tool formatters). The local copy is removed and the shared helper is imported.refactor: drop dead hasTrailingNewline ternary branches in getOutput—src/node/services/backgroundProcessManager.tshad twohasTrailingNewline ? allLines.slice(0, -1) : allLines.slice(0, -1)ternaries insidegetOutputwhose two branches were identical, so the condition never affected the result. Both are replaced with the unconditionalallLines.slice(0, -1). In the first occurrence the now-unusedhasTrailingNewlinelocal is also removed; in the second it is kept because it is still consulted when computingincompleteLineBuffer.refactor: extract shared stripModelProviderPrefixes helper—anthropicSupportsNativeXhigh(src/common/types/thinking.ts) andgetExplicitThinkingPolicy(src/common/utils/thinking/policy.ts) each inlined the identicaltrim → toLowerCase → strip 'provider:' → strip 'namespace/'chain to reduce a model string to its bare model id for capability matching. The chain moves into a new exportedstripModelProviderPrefixeshelper inthinking.ts; both call sites now use it. IngetExplicitThinkingPolicythe two intermediate locals (normalized,withoutPrefix) collapse into the singlewithoutProviderNamespacethe helper returns.Background
These cleanups remove duplicated or dead logic that drifts silently.
stripAnsiControlChars,formatBytes) that had been copied across files.hasTrailingNewline ? X : Xpattern inprocessMonitorContentbut left two identical instances ingetOutputuntouched.getExplicitThinkingPolicyandanthropicSupportsNativeXhighboth need the bare model id and had copy-pasted the same normalization. Consolidating it keeps capability predicates consistent about howprovider:prefixes and gatewaynamespace/segments are stripped.Implementation
stripAnsiControlChars(run 1): newsrc/node/utils/ansi.tsstrips ANSI/VT escape sequences and drops non-printable control characters (keeping tab and any code point >= 0x20). The regex was copied verbatim from the prior inline definitions, so it is byte-identical.formatBytesdedup (run 2): the local function inInstructionsTab.tsxis deleted andformatBytesis imported from@/common/utils/formatBytes; the shared helper is character-for-character equivalent, so the single call site renders identical output.hasTrailingNewlinededup (run 3): the two dead ternaries ingetOutputcollapse toallLines.slice(0, -1). The polling-loop occurrence dropped itshasTrailingNewlinedeclaration (it had no other use in that scope); the final-processing occurrence keeps the declaration sinceproc.incompleteLineBufferstill reads!hasTrailingNewline.stripModelProviderPrefixes(run 4): the new exported helper runs the same two.replace()calls in the same order as the prior inline chains, so it is behavior-identical.getThinkingDisplayLabelin the same file is intentionally left alone — it only strips theprovider:prefix and still inspectswithoutPrefix.startsWith("openai/"), so it needs the un-stripped namespace and does not fit this helper.Validation
bun test src/common/utils/thinking/policy.test.ts src/common/utils/ai/providerOptions.test.ts src/common/utils/ai/models.test.ts src/common/utils/tools/tools.test.ts(226 pass) exercises the normalization paths.make static-checkpasses for these TS-only changes (ESLint, both TypeScript configs, and Prettier all green). The run's only failure isfmt-shell-checkaborting becauseshfmtis not installed in this environment; the changes touch no shell/Docker files.Risks
None. All four cleanups are behavior-preserving: the shared helpers reuse the verbatim prior logic, and collapsing a
cond ? X : Xternary cannot change the result since both branches are identical.Auto-cleanup checkpoint: e1169d7
Generated with
mux• Model:anthropic:claude-opus-4-8• Thinking:xhigh• Cost:$0.00