Skip to content

Commit 7b1f94c

Browse files
authored
🤖 refactor: auto-cleanup (#3165)
## Summary Long-lived auto-cleanup PR that accumulates low-risk, behavior-preserving refactors picked from recent `main` commits. ## Current cleanup **Deduplicate identical `normalizeAdvisor*` helpers** (`src/browser/features/Settings/Sections/AdvisorToolExperimentConfig.tsx`) `normalizeAdvisorMaxUsesPerTurn` and `normalizeAdvisorMaxOutputTokens` had byte-for-byte identical function bodies (coerce a nullable number to a positive integer or return null). Replaced both with a single `normalizePositiveIntOrNull` helper. <details><summary>Previous cleanups</summary> **Remove dead `toLiveBashOutputView` function** (`src/browser/utils/messages/liveBashOutputBuffer.ts`) `toLiveBashOutputView` was exported but never imported or called anywhere in the codebase. Since `LiveBashOutputInternal extends LiveBashOutputView`, the `WorkspaceStore.getBashToolLiveOutput` returns the internal object directly for reference stability with `useSyncExternalStore`, making this converter function unnecessary dead code. </details> ## Validation - TypeScript compilation passes (both renderer and main configs) - ESLint passes - Advisor experiment settings tests pass (4/4) - Formatting check passes Auto-cleanup checkpoint: 7a2d18f --- _Generated with `mux` • Model: `anthropic:claude-opus-4-6` • Thinking: `xhigh` • Cost: `$-`_ <!-- mux-attribution: model=anthropic:claude-opus-4-6 thinking=xhigh costs=- --> --------- Co-authored-by: mux-bot[bot] <264182336+mux-bot[bot]@users.noreply.github.com>
1 parent 7a2d18f commit 7b1f94c

2 files changed

Lines changed: 4 additions & 23 deletions

File tree

src/browser/features/Settings/Sections/AdvisorToolExperimentConfig.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,8 @@ function normalizeAdvisorModelString(value: string | null | undefined): string |
5858
return trimmedValue;
5959
}
6060

61-
function normalizeAdvisorMaxUsesPerTurn(value: number | null | undefined): number | null {
62-
if (!Number.isInteger(value) || value == null || value <= 0) {
63-
return null;
64-
}
65-
66-
return value;
67-
}
68-
69-
function normalizeAdvisorMaxOutputTokens(value: number | null | undefined): number | null {
61+
/** Coerce a nullable number to a positive integer or null. */
62+
function normalizePositiveIntOrNull(value: number | null | undefined): number | null {
7063
if (!Number.isInteger(value) || value == null || value <= 0) {
7164
return null;
7265
}
@@ -198,10 +191,8 @@ export function AdvisorToolExperimentConfig() {
198191
const normalizedModelString = normalizeAdvisorModelString(cfg.advisorModelString);
199192
const normalizedThinkingLevel =
200193
coerceThinkingLevel(cfg.advisorThinkingLevel) ?? THINKING_LEVEL_OFF;
201-
const normalizedMaxUsesPerTurn = normalizeAdvisorMaxUsesPerTurn(cfg.advisorMaxUsesPerTurn);
202-
const normalizedMaxOutputTokens = normalizeAdvisorMaxOutputTokens(
203-
cfg.advisorMaxOutputTokens
204-
);
194+
const normalizedMaxUsesPerTurn = normalizePositiveIntOrNull(cfg.advisorMaxUsesPerTurn);
195+
const normalizedMaxOutputTokens = normalizePositiveIntOrNull(cfg.advisorMaxOutputTokens);
205196
// Match the backend starter cap when the setting is unset; only an explicit null is
206197
// the user's Unlimited opt-in.
207198
const nextMaxUsesMode: AdvisorMode =

src/browser/utils/messages/liveBashOutputBuffer.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,3 @@ export function appendLiveBashOutputChunk(
143143

144144
return next;
145145
}
146-
147-
export function toLiveBashOutputView(state: LiveBashOutputInternal): LiveBashOutputView {
148-
return {
149-
stdout: state.stdout,
150-
stderr: state.stderr,
151-
combined: state.combined,
152-
truncated: state.truncated,
153-
phase: state.phase,
154-
};
155-
}

0 commit comments

Comments
 (0)