Join Nostr
2026-04-04 03:17:33 UTC
in reply to

jonny (good kind) on Nostr: How many times does one need to declare an enum? Once? that's amateur hour. Try **ten ...

How many times does one need to declare an enum? Once? that's amateur hour. Try **ten times**. The way "effort" settings are handled are a masterclass in how you can make a single enum setting into thousands of lines of code.

The allowable effort values (not e.g. configuring which model has which effort levels, but just the possible strings one can use for effort) are defined in:<li>The main CLI arg parser</li><li><em>The body of the function that cycles effort levels in the TUI</em> - yes there is a <em>dedicated function for that</em></li><li>In <em>THREE</em> different schemas for agents, models, and SDK control messages</li><li>Three times in user-facing strings in the effort command (it also includes different explanatory strings from the effort.ts module)</li><li>The settings model, which only allows 'max' for anthropic employees</li><li>and finally, in the actual <code>effort.ts</code> file ... which also allows it to be a NUMBER!?</li>

The typical numerous fallback mechanisms provide *many* ways to get and set the effort value, at the end of *most* of them it goes "oh well, if we can't figure it out, just tell the user we are on high effort" because apparently that's the API default (ig pray that never changes!?) - of course there are *already* places in the *same module* that assume the default is "medium," and in the TUI that defaults to "low," so surely that consistency is bulletproof.

The EffortValue that allows effort to be a number is for anthropic employees only and is a good example of how new functionality is just shoved in there right alongside the old functionality, and *everywhere else that touches it doubles the surrounding code with fallbacks to account for the duplication.*

That cycleEffortLevel function is a true work of art, you simply could not make "indexing an array" more complicated than this (see components/ModelPicker.tsx for more gore). Reminder this should be *at most* a dozen or two lines for the values, description messages, and indexing logic in the TUI, but anthropic is up in the thousands FOR AN ENUM.