wave10: config hygiene (#97, #98) - #124
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR implements Wave 10 "Config Hygiene," addressing two defects: hard-coded ReCost base URLs scattered across multiple call sites and timestamp-only local scan ID generation with a 1ms collision window. It introduces two new modules ( ChangesWave 10 Config Hygiene
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/config.ts (1)
4-8: ⚡ Quick winNormalize trailing slashes for base URLs before export.
Line 5 and Line 8 trim whitespace but keep trailing
/. With downstream string concatenation, env overrides likehttps://host/becomehttps://host//projects....Suggested patch
const PROD_API_BASE_URL = "https://api.recost.dev"; const PROD_DASHBOARD_BASE_URL = "https://recost.dev"; +function resolveBaseUrl(value: string | undefined, fallback: string): string { + const trimmed = value?.trim(); + if (!trimmed) return fallback; + return trimmed.replace(/\/+$/, ""); +} + export const RECOST_API_BASE_URL = - process.env.RECOST_API_BASE_URL?.trim() || PROD_API_BASE_URL; + resolveBaseUrl(process.env.RECOST_API_BASE_URL, PROD_API_BASE_URL); export const RECOST_DASHBOARD_BASE_URL = - process.env.RECOST_DASHBOARD_BASE_URL?.trim() || PROD_DASHBOARD_BASE_URL; + resolveBaseUrl(process.env.RECOST_DASHBOARD_BASE_URL, PROD_DASHBOARD_BASE_URL);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/config.ts` around lines 4 - 8, The exported RECOST_API_BASE_URL and RECOST_DASHBOARD_BASE_URL currently trim whitespace but leave trailing slashes which can cause double-slash concatenation; update the initialization of both constants to remove any trailing slashes from the environment override (e.g., use process.env.RECOST_API_BASE_URL?.trim().replace(/\/+$/,'') || PROD_API_BASE_URL and similarly for RECOST_DASHBOARD_BASE_URL) so that downstream concatenation won't produce duplicate slashes while preserving protocol prefixes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/config.ts`:
- Around line 4-8: The exported RECOST_API_BASE_URL and
RECOST_DASHBOARD_BASE_URL currently trim whitespace but leave trailing slashes
which can cause double-slash concatenation; update the initialization of both
constants to remove any trailing slashes from the environment override (e.g.,
use process.env.RECOST_API_BASE_URL?.trim().replace(/\/+$/,'') ||
PROD_API_BASE_URL and similarly for RECOST_DASHBOARD_BASE_URL) so that
downstream concatenation won't produce duplicate slashes while preserving
protocol prefixes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 72ae64b2-c6fe-4ea6-81b6-80e7e15f856e
📒 Files selected for processing (18)
.gitignoredocs/superpowers/plans/2026-05-23-wave10-config-hygiene.mddocs/superpowers/specs/2026-05-22-wave8-status-error-ux-design.mddocs/superpowers/specs/2026-05-23-wave10-config-hygiene-design.mdpackage.jsonsrc/api-client.tssrc/chat/providers/eco.tssrc/cli/scan.tssrc/config.tssrc/extension.tssrc/scan-id.tssrc/test/config.test.tssrc/test/scan-id.test.tssrc/webview-provider.tssrc/webview/chat-handler.tssrc/webview/scan-publishing-handler.tstsconfig.scanner-tests.jsonwebview/tsconfig.tsbuildinfo
💤 Files with no reviewable changes (1)
- webview/tsconfig.tsbuildinfo
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…#98) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6fd2086 to
20a0771
Compare
Closes #97
Closes #98
Summary
src/config.tswith env-var overrides (RECOST_API_BASE_URL,RECOST_DASHBOARD_BASE_URL). Migrated 5 call sites acrossapi-client.ts,extension.ts,chat/providers/eco.ts,webview-provider.ts. Production behavior unchanged — defaults preserve the prior literals.scanIdgenerated aslocal-${Date.now()}— collision window of 1ms #98 — Replacedlocal-${Date.now()}withnewLocalScanId()from newsrc/scan-id.ts. Format:local-<unix_ms>-<8 hex chars>(32 bits of entropy in the suffix → collision probability is negligible past the prior 1ms window). Migrated 7 call sites acrosscli/scan.ts,webview/chat-handler.ts,webview/scan-publishing-handler.ts.Both fixes are orthogonal and additive. Format
^local-regex still matches the new scanId (verified no callsite splits on the inner structure).Test plan
npm run test:scanner— existing suite + newconfig(3 cases: defaults, env override, whitespace fallback) + newscan-id(3 cases: format regex, 1000-call uniqueness, monotonic timestamp) all pass.npm run build— dashboard + webview + extension build clean.api.recost.dev/recost.dev/dashboardonly insrc/config.ts(+ one JSDoc inregistry.ts, out of scope);local-${Date.now()}only insrc/scan-id.ts:11(the definition).Coexistence with Wave 8 (PR #123)
Wave 8 modifies the same four production files. If Wave 8 merges first, this branch needs a rebase that:
local-${Date.now()}site Wave 8 added in the 429 branch ofscan-publishing-handler.tstonewLocalScanId()(import already present).The grep gate will catch the 8th site automatically if missed.
Plan:
docs/superpowers/plans/2026-05-23-wave10-config-hygiene.md. Design spec:docs/superpowers/specs/2026-05-23-wave10-config-hygiene-design.md.🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
Refactor
Tests
Chores