Skip to content

fix(cli): doctor recognizes embedded file:// Postgres; quiet bundled-SPA Vite log#1033

Merged
buremba merged 1 commit into
mainfrom
feat/e2e-cli-polish
May 24, 2026
Merged

fix(cli): doctor recognizes embedded file:// Postgres; quiet bundled-SPA Vite log#1033
buremba merged 1 commit into
mainfrom
feat/e2e-cli-polish

Conversation

@buremba
Copy link
Copy Markdown
Member

@buremba buremba commented May 24, 2026

What

Three dev-experience fixes surfaced while end-to-end testing the published 9.3.0 CLI from a fresh /tmp install (bun install @lobu/cli@9.3.0, embedded Postgres, mock provider — exercising every CLI feature).

1. lobu doctor no longer false-fails the DB check on embedded Postgres

lobu init scaffolds DATABASE_URL=file://. (embedded PG) as the default, but doctor fed that straight into postgres(), which parses host "." and dies with getaddrinfo ENOTFOUND .:

✗ database: connect failed: getaddrinfo ENOTFOUND .

So every default project showed a scary DB failure on first lobu doctor. Now it branches on isExternalDatabaseUrl() (already exported by dev.ts) and reports the embedded backend:

✓ database: local embedded Postgres (data: <root>/.lobu/pgdata)

2. Quiet the misleading "frontend will not be available" log in lobu run

A bundled CLI sets WEB_DIST_DIR to the prebuilt SPA, which the Hono app serves statically. mountViteDev still probed for packages/owletto source, failed, and logged a full error stack claiming the frontend was unavailable — even though it was being served fine (HTTP 200). Now it skips Vite (with an info log) when WEB_DIST_DIR is set.

3. Add validate + doctor coverage to sdk-e2e.sh

The gate now asserts lobu validate accepts the fixture config and lobu doctor reports a healthy DB — the doctor assertion guards regression #1 (mode-aware: an external DATABASE_URL run still connects for real).

Validation

  • make build-packages + cli build green; tsc --noEmit clean for cli + server.
  • Full scripts/sdk-e2e.sh (with the new assertions) passes end-to-end, including the two new checks, the apply/prune lifecycle, a real worker turn, connector sync, watcher reaction, idempotent re-apply, and the @lobu/client SSE round-trip.
  • Verified in the run log: the old "frontend will not be available" warning is gone; the new "Serving prebuilt SPA from WEB_DIST_DIR" info log appears.

All three are pre-existing issues (not introduced by 9.3.0); the published release itself works correctly end-to-end.

Summary by CodeRabbit

  • New Features

    • Development server can now serve prebuilt web applications without requiring Vite
    • Database diagnostics improved to correctly handle local and external PostgreSQL configurations
  • Tests

    • Added CLI validation and database connectivity verification in the test suite

Review Change Stack

…SPA Vite log

Three dev-experience fixes surfaced by an end-to-end test of the published
9.3.0 CLI from a fresh /tmp install:

- doctor: the scaffold default is DATABASE_URL=file://. (embedded PG), but
  checkDatabaseAndPgvector fed that straight to postgres(), which parses host
  "." and fails with `getaddrinfo ENOTFOUND .` — so `lobu doctor` false-failed
  the DB check on every default project. Branch on isExternalDatabaseUrl() and
  report `local embedded Postgres (data: <root>/.lobu/pgdata)` for the embedded
  case, reusing the helpers dev.ts already exports.

- server (dev-vite): a bundled CLI sets WEB_DIST_DIR to the prebuilt SPA, which
  the Hono app serves statically. mountViteDev still probed for packages/owletto
  source, failed, and logged a misleading "frontend will not be available" error
  stack even though the frontend was being served. Skip Vite (with an info log)
  when WEB_DIST_DIR is set.

- sdk-e2e.sh: add `lobu validate` and `lobu doctor` assertions to the gate. The
  doctor assertion guards the regression above (no false connect failure on the
  embedded file:// default); it's mode-aware so an external DATABASE_URL run
  still connects for real.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 395a1226-d370-430c-bab1-9e4339c3c3f7

📥 Commits

Reviewing files that changed from the base of the PR and between 1e9fe29 and 2d2c373.

📒 Files selected for processing (3)
  • packages/cli/src/commands/doctor.ts
  • packages/server/src/dev-vite.ts
  • scripts/sdk-e2e.sh

📝 Walkthrough

Walkthrough

The PR improves local development diagnostics and deployment flexibility. The doctor command now distinguishes between external PostgreSQL connection strings and embedded filesystem Postgres paths, reporting appropriate status without attempting connections to local embedded databases. The dev server skips Vite initialization when a prebuilt SPA distribution is available. E2E tests validate the new diagnostic behavior during fixture setup.

Changes

CLI and Development Improvements

Layer / File(s) Summary
Doctor command database type detection
packages/cli/src/commands/doctor.ts
Imports isExternalDatabaseUrl and resolveEmbeddedDataRoot from dev.js. When DATABASE_URL is external, the command runs connectivity and pgvector checks via the existing checkDatabaseAndPgvector. When DATABASE_URL is local/embedded, it reports "local embedded Postgres" status with the resolved data root instead of attempting a connection.
Vite dev server prebuilt SPA optimization
packages/server/src/dev-vite.ts
mountViteDev checks process.env.WEB_DIST_DIR and returns null early when set, logging that the prebuilt SPA will be served and skipping Vite initialization.
E2E test validation for doctor command
scripts/sdk-e2e.sh
Adds a "static CLI checks" phase before test execution: runs lobu validate and asserts the fixture config is valid, runs lobu doctor and fails on database connection errors, and when using embedded Postgres asserts the doctor command reports "embedded Postgres" recognition.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • lobu-ai/lobu#985: mountViteDev behavior directly aligns with logic that computes and passes a default WEB_DIST_DIR pointing at the prebuilt owletto UI bundle.
  • lobu-ai/lobu#987: Both PRs handle embedded-vs-external DATABASE_URL distinctions for local development reliability, updating doctor diagnostics and dev.ts embedded URL detection patterns.

Poem

🐰 A rabbit hops through the CLI's glow,
Where doctor knows which way databases go—
Embedded or distant, each path now clear,
While Vite sleeps soundly when prebuilt draws near.
E2E tests check every hop and bound! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: fixing doctor command for embedded Postgres and quieting Vite logs in bundled SPA scenarios.
Description check ✅ Passed The description provides clear context for all three fixes with examples, validation steps performed, and explanations of the problem/solution.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/e2e-cli-polish

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@buremba
Copy link
Copy Markdown
Member Author

buremba commented May 24, 2026

bug_free 86, simplicity 91, slop 0, bugs 0, 0 blockers

Typecheck/unit passed. [env] integration aborted because DATABASE_URL points at database 'postgres', tripping the test-db safety guard; failing files are not in diff. Explored lobu doctor with DATABASE_URL=file://. (embedded DB ok, no ENOTFOUND) and imported mountViteDev with NODE_ENV=development WEB_DIST_DIR set (returned null/skip).

Full verdict JSON
{
  "bug_free_confidence": 86,
  "bugs": 0,
  "slop": 0,
  "simplicity": 91,
  "blockers": [],
  "change_type": "fix",
  "behavior_change_risk": "low",
  "tests_adequate": true,
  "suggested_fixes": [],
  "notes": "Typecheck/unit passed. [env] integration aborted because DATABASE_URL points at database 'postgres', tripping the test-db safety guard; failing files are not in diff. Explored `lobu doctor` with DATABASE_URL=file://. (embedded DB ok, no ENOTFOUND) and imported mountViteDev with NODE_ENV=development WEB_DIST_DIR set (returned null/skip).",
  "categories": {
    "src": 34,
    "tests": 22,
    "docs": 7,
    "config": 6,
    "deps": 22,
    "migrations": 0,
    "ci": 7,
    "generated": 0
  }
}

Local review gate — branch protection can require the pi-review commit status. See docs/REVIEW_SCHEMA.md.

@buremba buremba merged commit 0b53bd9 into main May 24, 2026
19 checks passed
@buremba buremba deleted the feat/e2e-cli-polish branch May 24, 2026 15:37
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