Skip to content

fix: load embedded dolt projects without starting server#78

Open
victorlitvinenko wants to merge 1 commit into
jdillon:mainfrom
victorlitvinenko:fix-embedded-dolt-start
Open

fix: load embedded dolt projects without starting server#78
victorlitvinenko wants to merge 1 commit into
jdillon:mainfrom
victorlitvinenko:fix-embedded-dolt-start

Conversation

@victorlitvinenko

@victorlitvinenko victorlitvinenko commented May 24, 2026

Copy link
Copy Markdown

Fix embedded Dolt projects in Dashboard and Issues

Summary

Fixes Dashboard and Issues loading for Beads projects that use embedded Dolt mode.

Recent bd versions can run with an embedded in-process Dolt engine. In that mode there is no Dolt SQL server, so bd dolt start fails with:

'bd dolt start' is not supported in embedded mode (no Dolt server)

The extension previously always created the Dolt SQL backend for active projects. That path can try to start a Dolt server while loading Dashboard or Issues, which breaks embedded-mode workspaces.

Changes

  • Add backend selection based on bd dolt show --json.
  • Use the existing CLI backend for embedded Dolt projects.
  • Keep the Dolt SQL backend for server-mode projects.
  • Fall back to the previous Dolt SQL backend behavior if mode detection fails.
  • Change CLI list loading to use bd list --all --limit 0 --json, so the Issues All filter can show closed issues too.
  • Add regression tests for embedded, server-mode, detection-failure, and CLI list argument behavior.
  • Document the fix in CHANGELOG.md.

Testing

  • bun run test
  • bun run compile:quiet
  • bun run lint

Manual checks:

  • Opened an embedded Dolt Beads workspace in Extension Development Host.
  • Dashboard and Issues no longer show the bd dolt start embedded-mode error.
  • Switching Issues from Not Closed to All shows closed issues that were hidden by the CLI default filter.

Summary by CodeRabbit

  • Bug Fixes

    • Embedded Dolt projects now load Dashboard and Issues through the CLI backend without requiring bd dolt start
    • The All filter now includes closed issues
  • Documentation

    • Updated changelog with latest improvements

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR adds embedded Dolt project detection to automatically select between CLI and SQL backends. A new BeadsBackendFactory module runs dolt show --json to detect embedded mode, instantiates the correct backend, and integrates into project activation. CLI list command arguments are refactored into a reusable helper, and the changelog documents the feature.

Changes

Embedded Dolt Backend Detection and Integration

Layer / File(s) Summary
Backend detection factory and type system
src/backend/BeadsBackendFactory.ts, src/backend/__tests__/BeadsBackendFactory.test.ts
New createBeadsBackend factory detects embedded vs. server-mode Dolt by running dolt show --json and parsing JSON through isEmbeddedDoltInfo. selectBackendKind returns "cli" for embedded projects and "dolt-sql" for server mode (with error fallback). Tests verify backend selection for both modes and error handling.
List command argument standardization
src/backend/BeadsCommandRunner.ts, src/backend/__tests__/BeadsCommandRunner.test.ts
createListCommandArgs helper centralizes the bd list --all --limit 0 --json argument list. BeadsCommandRunner.list() uses this helper instead of inline arguments. Tests verify the argument array structure.
Project manager integration of factory
src/backend/BeadsProjectManager.ts
activateProject replaces new BeadsDoltBackend() with async createBeadsBackend() call, enabling automatic backend selection during project initialization. Import updated to use the new factory.
Release notes documentation
CHANGELOG.md
Changelog entry documents that embedded Dolt projects now load Dashboard and Issues through the CLI backend without running bd dolt start, and closed issues are included in the All filter.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • jdillon/vscode-beads#69: Continues the backend refactor by changing BeadsProjectManager to instantiate the correct backend via new BeadsBackendFactory and refactoring BeadsCommandRunner.list() argument construction, both directly overlapping the same backend initialization code introduced in #69.

Poem

🐰 A factory hops in to detect Dolt's soul,
Embedded or SQL—it checks the whole,
CLI when snug, or SQL when wide,
Backend selection, your new trusty guide!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: enabling embedded dolt projects to load without starting a server, which is the core problem being fixed across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (4)
src/backend/__tests__/BeadsCommandRunner.test.ts (1)

1-1: ⚡ Quick win

Rename this new test file to kebab-case.

BeadsCommandRunner.test.ts should be renamed to kebab-case to satisfy repository naming conventions.
As per coding guidelines "Use kebab-case for source code, docs, and configs (e.g., my-module.ts, api-reference.md)."

🤖 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/backend/__tests__/BeadsCommandRunner.test.ts` at line 1, Rename the test
file from PascalCase to kebab-case to match repo conventions: change
src/backend/__tests__/BeadsCommandRunner.test.ts to
src/backend/__tests__/beads-command-runner.test.ts and update any
references/imports accordingly (e.g., the import of createListCommandArgs from
"../BeadsCommandRunner" if relative paths or test globs rely on filename);
ensure test runner and CI picks up the renamed file and run tests to verify
nothing else needs path updates.
src/backend/__tests__/BeadsBackendFactory.test.ts (2)

29-35: ⚡ Quick win

Add an assertion for onDetectionError invocation.

You verify fallback behavior, but not whether the optional detection-error callback is actually called. Adding this assertion protects error observability behavior from regressions.

Patch suggestion
   it("falls back to the Dolt SQL backend when mode detection fails", async () => {
+    const onDetectionError = jest.fn();
     const kind = await selectBackendKind(async () => {
       throw new Error("bd dolt show failed");
-    });
+    }, onDetectionError);
 
     expect(kind).toBe("dolt-sql");
+    expect(onDetectionError).toHaveBeenCalledTimes(1);
   });
🤖 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/backend/__tests__/BeadsBackendFactory.test.ts` around lines 29 - 35, The
test for selectBackendKind should also assert that the optional onDetectionError
callback is invoked when mode detection throws; update the test in
BeadsBackendFactory.test.ts to pass a jest.fn() (or sinon spy) as the
onDetectionError argument to selectBackendKind and add an expectation that this
spy was called once and received the thrown Error (or at least has been called),
referencing selectBackendKind and onDetectionError to locate where to attach the
spy and the assertion.

1-1: ⚡ Quick win

Rename this new test file to kebab-case.

BeadsBackendFactory.test.ts should use kebab-case to match repository naming rules.
As per coding guidelines "Use kebab-case for source code, docs, and configs (e.g., my-module.ts, api-reference.md)."

🤖 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/backend/__tests__/BeadsBackendFactory.test.ts` at line 1, Rename the test
file from BeadsBackendFactory.test.ts to kebab-case (e.g.,
beads-backend-factory.test.ts) to follow repository naming rules; keep the test
contents (including the import of selectBackendKind) unchanged and update any
references or test runner patterns if they explicitly list the old filename so
the test suite still discovers it.
src/backend/BeadsBackendFactory.ts (1)

1-1: ⚡ Quick win

Rename this new file to kebab-case.

BeadsBackendFactory.ts does not follow the repository naming convention for .ts files. Please rename it (and imports) to kebab-case before merge.
As per coding guidelines "Use kebab-case for source code, docs, and configs (e.g., my-module.ts, api-reference.md)."

🤖 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/backend/BeadsBackendFactory.ts` at line 1, The file name
BeadsBackendFactory.ts violates the kebab-case naming guideline; rename the file
to beads-backend-factory.ts and update all corresponding imports/usages (e.g.,
import/require statements that reference "BeadsBackendFactory" or paths to that
module) to the new kebab-case path; also rename any default export or class
identifier if your style requires matching file name (e.g., class or export
named BeadsBackendFactory can remain, but ensure type-only imports or tooling
that expects file-name casing are updated); run the project build/tests to
verify no import errors remain.
🤖 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.

Inline comments:
In `@CHANGELOG.md`:
- Line 13: Update the changelog entry that reads "Embedded Dolt projects now
load Dashboard and Issues through the CLI backend without calling `bd dolt
start`, including closed issues for the `All` filter." to include the required
bead reference token (e.g., append or prepend a token like `vsbeads-xxx`) so the
entry conforms to the guideline requiring bead references; ensure the bead token
is placed adjacent to the entry text and follows the existing changelog
formatting convention.

In `@src/backend/BeadsBackendFactory.ts`:
- Around line 34-40: The factory currently returns BeadsDoltBackend for the
non-embedded branch which bypasses the CLI; update the logic in
BeadsBackendFactory so that when kind === "cli" or in the non-embedded branch it
instantiates and returns BeadsCommandRunner(params) instead of
BeadsDoltBackend(params), and update the corresponding log message from "Using
Dolt SQL backend" to reflect the CLI backend; refer to the BeadsBackendFactory
function and the BeadsCommandRunner / BeadsDoltBackend symbols to locate and
change the returned class and log string.
- Around line 65-72: The execFileAsync call that runs params.bdPath with
["dolt","show","--json"] can hang because it has no timeout; add a timeout
property (e.g., 30_000 ms) to the options object passed to execFileAsync (the
same object that contains cwd, env, maxBuffer) and update the surrounding await
to catch timeout errors (check for error.code === 'ETIMEDOUT' or similar) so you
can log/throw a clear error and avoid blocking activation; reference the
existing execFileAsync invocation and params.bdPath/params.cwd/params.beadsDir
symbols when making the change.

---

Nitpick comments:
In `@src/backend/__tests__/BeadsBackendFactory.test.ts`:
- Around line 29-35: The test for selectBackendKind should also assert that the
optional onDetectionError callback is invoked when mode detection throws; update
the test in BeadsBackendFactory.test.ts to pass a jest.fn() (or sinon spy) as
the onDetectionError argument to selectBackendKind and add an expectation that
this spy was called once and received the thrown Error (or at least has been
called), referencing selectBackendKind and onDetectionError to locate where to
attach the spy and the assertion.
- Line 1: Rename the test file from BeadsBackendFactory.test.ts to kebab-case
(e.g., beads-backend-factory.test.ts) to follow repository naming rules; keep
the test contents (including the import of selectBackendKind) unchanged and
update any references or test runner patterns if they explicitly list the old
filename so the test suite still discovers it.

In `@src/backend/__tests__/BeadsCommandRunner.test.ts`:
- Line 1: Rename the test file from PascalCase to kebab-case to match repo
conventions: change src/backend/__tests__/BeadsCommandRunner.test.ts to
src/backend/__tests__/beads-command-runner.test.ts and update any
references/imports accordingly (e.g., the import of createListCommandArgs from
"../BeadsCommandRunner" if relative paths or test globs rely on filename);
ensure test runner and CI picks up the renamed file and run tests to verify
nothing else needs path updates.

In `@src/backend/BeadsBackendFactory.ts`:
- Line 1: The file name BeadsBackendFactory.ts violates the kebab-case naming
guideline; rename the file to beads-backend-factory.ts and update all
corresponding imports/usages (e.g., import/require statements that reference
"BeadsBackendFactory" or paths to that module) to the new kebab-case path; also
rename any default export or class identifier if your style requires matching
file name (e.g., class or export named BeadsBackendFactory can remain, but
ensure type-only imports or tooling that expects file-name casing are updated);
run the project build/tests to verify no import errors remain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 88986c8c-2398-4b68-87d6-c3aa4731d913

📥 Commits

Reviewing files that changed from the base of the PR and between b2a1e66 and 2d6b8da.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • src/backend/BeadsBackendFactory.ts
  • src/backend/BeadsCommandRunner.ts
  • src/backend/BeadsProjectManager.ts
  • src/backend/__tests__/BeadsBackendFactory.test.ts
  • src/backend/__tests__/BeadsCommandRunner.test.ts

Comment thread CHANGELOG.md
### Fixed

- `beads.userId` and `beads.pathToBd` now expand `${env:VAR}` placeholders (#60)
- Embedded Dolt projects now load Dashboard and Issues through the CLI backend without calling `bd dolt start`, including closed issues for the `All` filter.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add a bead reference to this changelog entry.

This new notable fix entry is missing the required bead reference token (for example, vsbeads-xxx).

Suggested edit
-- Embedded Dolt projects now load Dashboard and Issues through the CLI backend without calling `bd dolt start`, including closed issues for the `All` filter.
+- Embedded Dolt projects now load Dashboard and Issues through the CLI backend without calling `bd dolt start`, including closed issues for the `All` filter (`vsbeads-xxx`).

As per coding guidelines, "Keep entries terse with bead references (e.g., vsbeads-xxx)."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Embedded Dolt projects now load Dashboard and Issues through the CLI backend without calling `bd dolt start`, including closed issues for the `All` filter.
- Embedded Dolt projects now load Dashboard and Issues through the CLI backend without calling `bd dolt start`, including closed issues for the `All` filter (`vsbeads-xxx`).
🤖 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 `@CHANGELOG.md` at line 13, Update the changelog entry that reads "Embedded
Dolt projects now load Dashboard and Issues through the CLI backend without
calling `bd dolt start`, including closed issues for the `All` filter." to
include the required bead reference token (e.g., append or prepend a token like
`vsbeads-xxx`) so the entry conforms to the guideline requiring bead references;
ensure the bead token is placed adjacent to the entry text and follows the
existing changelog formatting convention.

Comment on lines +34 to +40
if (kind === "cli") {
params.log.info("Using bd CLI backend for embedded Dolt project");
return new BeadsCommandRunner(params);
}

params.log.info("Using Dolt SQL backend");
return new BeadsDoltBackend(params);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Factory still routes to a non-CLI backend.

The non-embedded branch instantiates BeadsDoltBackend, which routes Beads operations through Dolt SQL rather than CLI. That conflicts with the backend rule for src/backend/**/*.ts.
As per coding guidelines "All Beads operations must go through CLI (bd list --json, bd show <id> --json, etc.). Never access .beads files directly."

🤖 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/backend/BeadsBackendFactory.ts` around lines 34 - 40, The factory
currently returns BeadsDoltBackend for the non-embedded branch which bypasses
the CLI; update the logic in BeadsBackendFactory so that when kind === "cli" or
in the non-embedded branch it instantiates and returns
BeadsCommandRunner(params) instead of BeadsDoltBackend(params), and update the
corresponding log message from "Using Dolt SQL backend" to reflect the CLI
backend; refer to the BeadsBackendFactory function and the BeadsCommandRunner /
BeadsDoltBackend symbols to locate and change the returned class and log string.

Comment on lines +65 to +72
const { stdout } = await execFileAsync(params.bdPath, ["dolt", "show", "--json"], {
cwd: params.cwd,
env: {
...process.env,
BEADS_DIR: params.beadsDir,
},
maxBuffer: 1024 * 1024,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add a timeout to backend-mode detection command execution.

This activation-path bd dolt show --json call has no timeout, so a hung process can block project activation indefinitely.

Patch suggestion
   const { stdout } = await execFileAsync(params.bdPath, ["dolt", "show", "--json"], {
     cwd: params.cwd,
     env: {
       ...process.env,
       BEADS_DIR: params.beadsDir,
     },
     maxBuffer: 1024 * 1024,
+    timeout: 5000,
+    killSignal: "SIGTERM",
   });
🤖 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/backend/BeadsBackendFactory.ts` around lines 65 - 72, The execFileAsync
call that runs params.bdPath with ["dolt","show","--json"] can hang because it
has no timeout; add a timeout property (e.g., 30_000 ms) to the options object
passed to execFileAsync (the same object that contains cwd, env, maxBuffer) and
update the surrounding await to catch timeout errors (check for error.code ===
'ETIMEDOUT' or similar) so you can log/throw a clear error and avoid blocking
activation; reference the existing execFileAsync invocation and
params.bdPath/params.cwd/params.beadsDir symbols when making the change.

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.

1 participant