Skip to content

Conversation

@radon-at-beeper
Copy link
Contributor

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Adds a --local-dev (-l) flag to the bbctl delete command to target bridge data in the current working directory and updates README guidance to recommend using bbctl delete -l for locally-run bridges, replacing prior manual cleanup instructions. (49 words)

Changes

Cohort / File(s) Change Summary
Documentation
README.md
Simplified "Deleting bridges" guidance to instruct using bbctl delete -l for bridges created with bbctl run -l; removed previous multi-location/manual deletion notes and condensed warning about re-adding self-hosted bridges after deletion.
CLI delete command
cmd/bbctl/delete.go
Added --local-dev / -l boolean flag. Added isLocalBridgeFile() to identify local bridge files and deleteLocalBridgeData() to either remove the whole directory or selectively delete local bridge files; replaced direct dir deletion with new helper and adjusted messaging/confirm flow.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether it relates to the changeset. Add a pull request description explaining the purpose and context of the changes, such as why the -l flag was added and how it affects users.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main change: adding a --local-dev flag to the delete command for removing config and database in the current directory, which aligns with both the cmd/bbctl/delete.go changes and the README.md documentation update.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rr-delete-local-dev

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

@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 `@cmd/bbctl/delete.go`:
- Around line 57-65: The current --local-dev flow uses os.Getwd() (localDev) and
then deletes files matched by isLocalBridgeFile, which can remove unrelated
config/SQLite files if run from the wrong directory; update the delete command
(around localDev, os.Getwd(), and the isLocalBridgeFile usage) to add a safety
guard: verify the target directory is a bbctl bridge directory (e.g., check for
a specific marker/config file or expected bridge files), and if verification
fails require an explicit confirmation flag or interactive confirmation that
prints the absolute paths and file list to be deleted before proceeding; ensure
the code path that sets bridgeDir and the subsequent deletion logic exits unless
the verification/confirmation succeeds.
🧹 Nitpick comments (1)
cmd/bbctl/delete.go (1)

129-129: Use filepath.Join for filesystem paths.

Line 129 uses path.Join which is intended for forward-slash-separated paths like URLs. Since os.Remove() is a filesystem operation, use filepath.Join instead to properly handle OS-specific path separators and Windows semantics.

♻️ Proposed fix
-import "path"
+// path import removed; using filepath.Join for filesystem paths
...
- err := os.Remove(path.Join(bridgeDir, item.Name()))
+ err := os.Remove(filepath.Join(bridgeDir, item.Name()))

Comment on lines +57 to +65
localDev := ctx.Bool("local-dev")
if localDev {
bridgeDir, err = os.Getwd()
if err != nil {
return fmt.Errorf("failed to get working directory: %w", err)
}
} else {
bridgeDir = filepath.Join(dataDir, bridge)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Local-dev deletion can wipe unrelated data in the current directory.

--local-dev targets os.Getwd() and isLocalBridgeFile matches any config.yaml or *.db*. If the command is run from the wrong directory, unrelated config/SQLite files can be removed. Consider adding a stronger guard (e.g., validate the directory is a bbctl bridge dir or include the absolute path + file list in an explicit confirmation before deletion).

💡 Possible safety guard (example)
- err = survey.AskOne(&survey.Confirm{Message: fmt.Sprintf("Are you sure you want to permanently delete %s?", bridge)}, &confirmation)
+ confirmMsg := fmt.Sprintf("Are you sure you want to permanently delete %s?", bridge)
+ if localDev {
+   confirmMsg = fmt.Sprintf(
+     "Are you sure you want to permanently delete %s and remove local data in %s?",
+     bridge, bridgeDir,
+   )
+ }
+ err = survey.AskOne(&survey.Confirm{Message: confirmMsg}, &confirmation)

Also applies to: 103-133

🤖 Prompt for AI Agents
In `@cmd/bbctl/delete.go` around lines 57 - 65, The current --local-dev flow uses
os.Getwd() (localDev) and then deletes files matched by isLocalBridgeFile, which
can remove unrelated config/SQLite files if run from the wrong directory; update
the delete command (around localDev, os.Getwd(), and the isLocalBridgeFile
usage) to add a safety guard: verify the target directory is a bbctl bridge
directory (e.g., check for a specific marker/config file or expected bridge
files), and if verification fails require an explicit confirmation flag or
interactive confirmation that prints the absolute paths and file list to be
deleted before proceeding; ensure the code path that sets bridgeDir and the
subsequent deletion logic exits unless the verification/confirmation succeeds.

@radon-at-beeper radon-at-beeper requested a review from tulir January 27, 2026 18:05
@radon-at-beeper radon-at-beeper requested a review from tulir January 27, 2026 22:00
@tulir tulir changed the title Support 'bbctl delete -l' Add --local-dev flag to delete config and database in current directory Jan 27, 2026
@radon-at-beeper radon-at-beeper merged commit 3afaaf5 into main Jan 27, 2026
11 checks passed
@radon-at-beeper radon-at-beeper deleted the rr-delete-local-dev branch January 27, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants