Skip to content

Fix fresh-install DB crash (missing selected_mcp_server_ids_json) and resolve MCP settings merge conflicts - #2

Open
TecnicalBot wants to merge 12 commits into
devfrom
fix/db-schema-and-merge-conflicts
Open

Fix fresh-install DB crash (missing selected_mcp_server_ids_json) and resolve MCP settings merge conflicts#2
TecnicalBot wants to merge 12 commits into
devfrom
fix/db-schema-and-merge-conflicts

Conversation

@TecnicalBot

Copy link
Copy Markdown
Owner

What & why

Two problems on dev:

1. Fresh installs crash: conversations is missing selected_mcp_server_ids_json

migrateAppDatabase builds the full v14 schema in one shot for fresh installs (user_version 0 jumps straight to DATABASE_VERSION), but the v0 CREATE TABLE conversations never included selected_mcp_server_ids_json. The column was only ever added by the v12/v13 migration path, which never runs on fresh installs. Result: every new install (including the installed test build) crashes on any SQL that reads/writes that column.

Fix in src/core/db/migrations.ts:

  • Added selected_mcp_server_ids_json TEXT to the v0 CREATE TABLE conversations.
  • Added an idempotent repair to the currentVersion >= DATABASE_VERSION early-return path: it checks PRAGMA table_info(conversations) and ALTER TABLE ... ADD COLUMN if the column is missing. Existing installs that already landed on version 14 without the column now self-heal on next launch — no reinstall needed.

2. Unresolved stash-pop conflict markers in MCP settings screens

src/app/(root)/settings/mcp/add.tsx and src/app/(root)/settings/mcp/list.tsx contained live <<<<<<< Updated upstream / ======= / >>>>>>> Stashed changes markers.

Resolution (both files):

  • Kept the @/modules/mcp/... module paths (the old @/lib/mcp/... path no longer exists on dev).
  • Kept fetchMcpServerCatalogCached from @/modules/mcp/catalog — the dev call sites use it and it is what the module exports (verified against src/modules/mcp/catalog.ts).
  • list.tsx keeps isMcpOAuthCanceledError from @/modules/mcp/oauth (verified exported).

Files changed

  • src/core/db/migrations.ts — v0 schema fix + defensive repair on the latest-version path
  • src/app/(root)/settings/mcp/add.tsx — conflict markers resolved
  • src/app/(root)/settings/mcp/list.tsx — conflict markers resolved

Verification

  • Confirmed no <<<<<<</>>>>>>> markers remain in either settings file.
  • Confirmed both imports resolve against current dev modules.
  • Confirmed add.tsx was already correctly resolved and left untouched except for the earlier conflict-resolution commit.

- migrations.ts: add the missing selected_mcp_server_ids_json column to
  the conversations table created on fresh installs (version 0). The v0
  path jumps straight to DATABASE_VERSION=14, so the v12/v13 ALTERs that
  add this column were being skipped for new installs, causing
  "no such column: selected_mcp_server_ids_json" on every Drizzle query
  against conversations at app open.
- add.tsx / list.tsx: resolve leftover git stash-pop conflict markers.
  Keep the dev @/modules/mcp/* import paths and the new
  fetchMcpServerCatalogCached API added in the previous commit.
…flict

The previous commit accidentally included a truncated reconstruction of
list.tsx. This replaces it with the exact original content (including the
catalogPresets/PresetRow rendering) with only the stash-pop conflict markers
resolved: keep the dev @/modules/mcp/* import paths and use
fetchMcpServerCatalogCached.
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