Load bead labels from config.toml instead of hardcoding 'ralph'#193
Load bead labels from config.toml instead of hardcoding 'ralph'#193
Conversation
The convert --to beads command was hardcoding 'ralph' as a label for all created epics and tasks. This caused issues because the TUI filters by configured labels, meaning newly converted items wouldn't appear. Changes: - Remove hardcoded 'ralph' label from convertToBeads function - Load labels from trackerOptions.labels in config.toml when CLI labels are not provided - Only add --labels flag to bd commands when labels are actually configured - Update help text to reflect new behavior Fixes #171
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Walkthroughconvert.ts now resolves beads labels by preferring CLI-provided labels, then loading defaults from a stored config (config.toml) if CLI labels are absent; labels are injected into bead creation only when non-empty. The parameter name changed from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/commands/convert.ts`:
- Around line 599-603: The array branch handling for configLabels is
inconsistent with the string branch and may allow empty or whitespace-only
labels; update the Array.isArray(configLabels) branch so it mirrors the string
path: map each element to its trimmed version, then filter out non-strings and
empty/whitespace-only values before assigning to labels (use the existing
variables configLabels and labels and preserve a string type guard for
elements).
🧹 Nitpick comments (1)
src/commands/convert.ts (1)
255-258: Consider extracting label argument insertion into a helper.The same
splicepattern is repeated for both epic and story argument arrays (lines 255-258 and 308-311). While the implementation is correct, this could be extracted into a small helper function to reduce duplication.The current
indexOf('--priority')approach works because--priorityis always present in both arrays, but it's somewhat fragile if the argument structure changes.♻️ Optional refactor to reduce duplication
function addLabelsToArgs(args: string[], labelsStr: string): void { if (labelsStr) { const priorityIdx = args.indexOf('--priority'); if (priorityIdx !== -1) { args.splice(priorityIdx, 0, '--labels', labelsStr); } } }Then use:
- // Only add labels if configured - if (labelsStr) { - epicArgs.splice(epicArgs.indexOf('--priority'), 0, '--labels', labelsStr); - } + addLabelsToArgs(epicArgs, labelsStr);
Update the Array.isArray(configLabels) branch to mirror the string path: trim each element and filter out empty/whitespace-only values.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/commands/convert.ts (1)
581-607: CLI precedence can be bypassed when--labelsis missing/empty.As written,
labels || []collapses “flag absent” and “flag provided but empty”, so config labels get loaded even when--labelswas supplied. This violates the stated precedence and also hides missing-argument errors.🔧 Proposed fix (preserve absence vs empty, validate missing value)
@@ - } else if (arg === '--labels' || arg === '-l') { - const labelsStr = args[++i]; - labels = labelsStr ? labelsStr.split(',').map((l) => l.trim()).filter((l) => l.length > 0) : []; - } else if (arg === '--force' || arg === '-f') { + } else if (arg === '--labels' || arg === '-l') { + const labelsStr = args[++i]; + if (labelsStr === undefined || labelsStr.startsWith('-')) { + console.error('Error: --labels requires a value'); + return null; + } + labels = labelsStr.split(',').map((l) => l.trim()).filter((l) => l.length > 0); + } else if (arg === '--force' || arg === '-f') { @@ - await executeBeadsConversion(parsed, labels || [], verbose ?? false, input); + await executeBeadsConversion(parsed, labels, verbose ?? false, input); @@ - cliLabels: string[], + cliLabels?: string[], @@ - let labels = cliLabels; - if (labels.length === 0) { + let labels = cliLabels ?? []; + if (cliLabels === undefined) {
Load bead labels from config.toml instead of hardcoding 'ralph'
Summary
This PR removes the hardcoded 'ralph' label requirement and instead allows users to configure default labels for beads through
config.toml. The CLI--labelsflag still takes precedence when provided.Key Changes
loadStoredConfigto load configuration fromconfig.tomlconfig.toml [trackerOptions].labelsinstead of hardcoded 'ralph'convertToBeads()to conditionally add labels only when configured (instead of always including 'ralph')executeBeadsConversion()to load labels from config when not provided via CLI, with proper precedence: CLI args > config file > no labels--labelsflag when labels are actually configuredImplementation Details
--labelsCLI flag still takes full precedence over config file settingsSummary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.