Implement configuration resolution with deterministic precedence and reuse resolved values instead of re-deriving them in multiple places.
Standards
allowBindFallback: userProvided ?? derivedDefault.ctx.clineAppBaseUrl), and serve them without re-reading provider settings on each request.Illustrative snippets
// 1) Explicit option wins
const allowBindFallback = explicitAllowBindFallback ?? !hasExplicitEndpoint;
// 2) CLI vs env: only use CLI value when it was actually set on CLI
const mouse =
cmd.getOptionValueSource('mouse') === 'cli' ? cmd.opts().mouse : undefined;
const useMouse =
input.mouse !== undefined ? input.mouse : process.env.CLINE_MOUSE !== '0';
// 3) Single-source mapping: resolve backend once, map to app URL from it
const apiBaseUrl = resolveBackendApiBaseUrl();
const appBaseUrl = resolveClineAppBaseUrl(apiBaseUrl); // shared helper
// 4) Resolve once and reuse (sidecar/webview)
ctx.clineAppBaseUrl = appBaseUrl;
function get_cline_app_base_url() { return ctx.clineAppBaseUrl; }
Following these rules prevents the common class of bugs where the UI/link targets one environment while the backend call uses another, where env fallbacks are silently overridden by CLI defaults, or where explicit runtime options are ignored due to derived defaults.