🤖 refactor: auto-cleanup#3213
Open
mux-bot[bot] wants to merge 5 commits intomainfrom
Open
Conversation
d9afdaa to
708166d
Compare
Replace the inline `theme === "light" || theme === "flexoki-light"` check in `getColorScheme` with the shared `isLightThemeMode` helper from `shiki-shared.ts`, so the `-light` suffix convention has a single source of truth and stays consistent with the syntax-highlighting call sites that already use it.
…stions The skill and model alias build callbacks in getSlashCommandSuggestions hardcode the trailing space, so the appendSpace: true property on those SuggestionDefinition literals is dead. Remove it and add a brief comment explaining why we don't propagate appendSpace through these paths so a future reader doesn't assume the field is consulted there.
The OpenAI service-tier literal union ('auto' | 'default' | 'flex' |
'priority') was duplicated in three places: the CLI options interface
(src/cli/run.ts), the providerModelFactory cast at the providers.jsonc
boundary, and a local OpenAIServiceTier alias in ProvidersSection.tsx.
ServiceTierSchema (src/common/config/schemas/providersConfig.ts)
already defines this enum as the runtime source of truth, so derive a
TypeScript ServiceTier alias via z.infer once and import it at each
site. Pure type-only refactor; the emitted JS and the schema remain
unchanged.
The shape `{ model: string; thinkingLevel?: ThinkingLevel }` (used
internally to read per-agent AI settings off partial workspace metadata)
was duplicated 7 times across the parameter and return types of
`resolveWorkspaceAISettings`, `resolveTaskAISettings`, and
`resolveParentAutoResumeOptions`. The new sub-agent defaults split
(#3215) made this duplication especially visible because it added a
third method copying the same inline shape.
Introduce a private `ResolvedWorkspaceAiSettings` interface at module
scope and use it everywhere. Pure type-level cleanup — emitted JS,
runtime behavior, and the schema-derived `WorkspaceAISettings` type
(where `thinkingLevel` is required) are all unchanged.
🤖 _Generated with `mux` • Model: `anthropic:claude-opus-4-7` • Thinking: `xhigh`_
In `src/node/services/tools/file_edit_insert.ts`, `GuardAnchors` was defined as `Pick<InsertContentOptions, "insert_before" | "insert_after">`, but `InsertContentOptions` itself is already `Pick<FileEditInsertToolArgs, "insert_before" | "insert_after">` after the `.nullish()` strict-mode refactor in #2250 stripped the `InsertContentOptions` interface down to those same two fields. The two aliases are now structurally identical, so `GuardAnchors` is dead. Drop the alias and use `InsertContentOptions` for the two callers (`insertWithGuards`, `resolveGuardAnchor`). Both names were file-local; no exports change. The function names (`insertWithGuards`, `resolveGuardAnchor`) already convey "guard" context, so the parameter type doesn't need to repeat it. Pure type-level cleanup — emitted JS, runtime behavior, and the public tool surface are all unchanged.
Contributor
Author
|
Failed job: Failures (both in
What I checked:
No fix pushed. A re-run of |
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
Long-lived auto-cleanup PR that accumulates low-risk, behavior-preserving refactors picked from recent
maincommits.Changes
Drop redundant
GuardAnchorstype alias infile_edit_insertIn
src/node/services/tools/file_edit_insert.ts,GuardAnchorswas defined asPick<InsertContentOptions, "insert_before" | "insert_after">, butInsertContentOptionsitself is alreadyPick<FileEditInsertToolArgs, "insert_before" | "insert_after">after the.nullish()strict-mode refactor in #2250 stripped theInsertContentOptionsinterface down to those same two fields. The two aliases became structurally identical, soGuardAnchorsis dead.Drop the alias and use
InsertContentOptionsfor the two callers (insertWithGuards,resolveGuardAnchor). Both names were file-local; no exports change. The function names already convey "guard" context, so the parameter type doesn't need to repeat it. This noise was especially visible to the new guardless-empty-file path added in #3220 since it sits next toinsertContentwhich usesInsertContentOptions.Pure type-level cleanup — emitted JS, runtime behavior, and the public tool surface are all unchanged.
Previous cleanups
Extract
ResolvedWorkspaceAiSettingstype alias intaskServiceThe shape
{ model: string; thinkingLevel?: ThinkingLevel }(used internally to read per-agent AI settings off partial workspace metadata) was duplicated 7 times across the parameter and return types ofresolveWorkspaceAISettings,resolveTaskAISettings, andresolveParentAutoResumeOptionsinsrc/node/services/taskService.ts. The new sub-agent defaults split (#3215) made this duplication especially visible because it added a third method copying the same inline shape.A private
ResolvedWorkspaceAiSettingsinterface at module scope replaces all 7 inline occurrences. Pure type-level cleanup — emitted JS, runtime behavior, and the schema-derivedWorkspaceAISettingstype (wherethinkingLevelis required) are all unchanged. The new interface is intentionally local to this file (not exported) since it captures the looser internal-reader shape, distinct from the canonical schema-derived type.Extract shared
ServiceTiertype fromServiceTierSchemaThe OpenAI service-tier literal union (
"auto" | "default" | "flex" | "priority") was duplicated in three places: the CLI options interface (src/cli/run.ts), theproviderModelFactorycast at theproviders.jsoncboundary (src/node/services/providerModelFactory.ts), and a localOpenAIServiceTieralias inProvidersSection.tsx.ServiceTierSchema(src/common/config/schemas/providersConfig.ts) already defines the same enum as the runtime source of truth, so this change derives a TypeScriptServiceTieralias viaz.inferonce and imports it at each site.The Settings UI keeps its
OpenAIServiceTierlocal alias (used byOpenAIServiceTierSelectValueand theisOpenAIServiceTiertype guard) but it is nowtype OpenAIServiceTier = ServiceTier, so the disambiguating name and call sites stay intact.Drop unused
appendSpaceliterals on skill/model alias suggestionsIn
src/browser/utils/slashCommands/suggestions.ts, theSuggestionDefinitionliterals built for agent skills and model alias one-shots setappendSpace: true, but the build callbacks for those two paths hardcode the trailing space and never readdefinition.appendSpace. Only the top-level command and subcommand build callbacks consult the field. Remove the no-opappendSpace: truefrom the skill and model alias mappings and leave a short comment near each so a future reader doesn't assume the field is consulted on these paths.Behavior is preserved — the field is unread on these paths, and the existing
suggestions.test.ts/inlineSkillSuggestions.test.ts/suggestionMatching.test.tssuites all still pass.Route
ThemeContextcolor-scheme throughisLightThemeModeReplace the inline
theme === "light" || theme === "flexoki-light"check ingetColorScheme(insrc/browser/contexts/ThemeContext.tsx) with the sharedisLightThemeModehelper fromsrc/browser/utils/highlighting/shiki-shared.ts.The helper was just introduced as the single source of truth for the
-lightsuffix → light-theme mapping, and the highlighting call sites (MarkdownComponents,HighlightedCode,highlightDiffChunk) already use it. This change extends that convention toThemeContextso a future palette likesolarized-lightwould automatically map tocolorScheme: "light"without revisiting this site.Behavior is preserved: for the four valid
ThemeModevalues ("light","dark","flexoki-light","flexoki-dark"),isLightThemeModereturns the same result as the previous explicit comparison.Validation
bun test src/node/services/tools/file_edit_insert.test.ts— 16/16 pass.make static-check— eslint, tsgo (×2), prettier all pass; onlyshfmtfails because the binary is unavailable in this environment, and no shell files are touched.Risks
Minimal — purely a TypeScript type alias removal local to one file. The emitted JS is unchanged, no exported types or APIs are touched, and
InsertContentOptionsis structurally identical to the removedGuardAnchors(bothPickthe same two fields fromFileEditInsertToolArgs).Auto-cleanup checkpoint: af4912e
Generated with
mux• Model:anthropic:claude-opus-4-7• Thinking:xhigh