Skip to content

Load bead labels from config.toml instead of hardcoding 'ralph'#193

Merged
subsy merged 2 commits intomainfrom
claude/fix-issue-171-6SD1l
Jan 22, 2026
Merged

Load bead labels from config.toml instead of hardcoding 'ralph'#193
subsy merged 2 commits intomainfrom
claude/fix-issue-171-6SD1l

Conversation

@subsy
Copy link
Owner

@subsy subsy commented Jan 22, 2026

Summary

This PR removes the hardcoded 'ralph' label requirement and instead allows users to configure default labels for beads through config.toml. The CLI --labels flag still takes precedence when provided.

Key Changes

  • Added import of loadStoredConfig to load configuration from config.toml
  • Updated help text to reference config.toml [trackerOptions].labels instead of hardcoded 'ralph'
  • Modified convertToBeads() to conditionally add labels only when configured (instead of always including 'ralph')
  • Updated executeBeadsConversion() to load labels from config when not provided via CLI, with proper precedence: CLI args > config file > no labels
  • Refactored label argument insertion to only add --labels flag when labels are actually configured
  • Updated command description to reflect the new configurable behavior

Implementation Details

  • Labels are now optional rather than mandatory
  • The --labels CLI flag still takes full precedence over config file settings
  • Config labels support both string (comma-separated) and array formats
  • Labels are properly trimmed and filtered to remove empty values
  • The change maintains backward compatibility for users who have configured labels in their config file

Summary by CodeRabbit

  • New Features

    • Bead conversion now loads default labels from your config when no CLI labels are provided; CLI labels take precedence. Labels are only applied when a non-empty set exists.
  • Documentation

    • Updated help text and usage guidance to explain label precedence and that defaults can come from your configuration file.

✏️ Tip: You can customize this high-level summary in your review settings.

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
@vercel
Copy link

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
ralph-tui Ignored Ignored Preview Jan 22, 2026 4:32pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

Walkthrough

convert.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 labels to cliLabels.

Changes

Cohort / File(s) Summary
Beads Conversion Label Loading
src/commands/convert.ts
Added loading of stored config labels when CLI labels are not supplied; renamed function parameter labelscliLabels; conditional injection of --labels for epic/story creation only when label string is non-empty; updated CLI help/usage text to reflect config-source labels.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I hopped through code at break of dawn,
Found labels sleeping in config lawn,
CLI first, then toml’s sweet song,
Beads now wear tags where they belong. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarises the main change: moving from a hardcoded 'ralph' label to loading labels from config.toml, which is the primary objective of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 splice pattern 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 --priority is 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.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --labels is missing/empty.

As written, labels || [] collapses “flag absent” and “flag provided but empty”, so config labels get loaded even when --labels was 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) {

@subsy subsy merged commit 6d0d1d0 into main Jan 22, 2026
9 checks passed
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
Load bead labels from config.toml instead of hardcoding 'ralph'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments