refactor: flatten nested call chains#26350
Many call sites nested plain function calls three or more levels deep, so you read them inside out. The most common case was Option.getOrNull(AsyncResult.value(x)), which hand-inlines what AsyncResult already provides. I found them with an AST scan of the repo (oxc-parser), looking for calls passed as another call's first argument at least three levels deep.
What changed:
Option.getOrElse(AsyncResult.value(x), f)becomesAsyncResult.getOrElse(x, f), andOption.getOrNull(AsyncResult.value(x))becomesAsyncResult.getOrElse(x, () => null). Effect definesAsyncResult.getOrElseas exactly that composition, so behaviour is unchanged. 82 sites; theOptionimports this left unused are removed.- About 40 chains that pass one value through several steps (
removeLogged(storeName(refFor(…))),setError(message(squashAtomCommandFailure(result))), the theme colour solve, the MCP asset HTML rewrite, and others) now read top to bottom withpipefromeffect/Function. Effect and Stream values use.pipeinstead. - The six identical
sortProviderInstanceEntries(applyProviderInstanceSettings(deriveProviderInstanceEntries(…)))chains now call one helper,providerInstanceEntriesFor.sortProviderInstanceEntrieshad no other callers, so it is now private.
Left as they were: chains where the inner calls only build one argument of a call that has other arguments too, such as provide(runSshCommand(targetFor(config), {…})) and anchorNewTurn(scopedThreadKey(scopeThreadRef(…)), messageId). Rewriting those as pipe would need a lambda for nearly every step.
vp run check:changed passes: format, lint, knip, typecheck of 32 packages, and 61 test files.
Model: Claude Opus 5.5 via Claude Code in T3 Code.
🤖 Generated with Claude Code
Checks
Failing1
- CodeRabbitGitHubCancelled
Added 1 commit
- refactor: flatten nested call chains785fae2