Skip to content

refactor: architecture extensibility (P1–P6) - #10

Merged
pavi2410 merged 7 commits into
mainfrom
feat/architecture-extensibility
Jun 1, 2026
Merged

refactor: architecture extensibility (P1–P6)#10
pavi2410 merged 7 commits into
mainfrom
feat/architecture-extensibility

Conversation

@pavi2410

@pavi2410 pavi2410 commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

Six prioritised refactors that make Based structurally ready for the upcoming roadmap (new DB engines, auth methods, LSP support, ER diagrams, agent chat, CLI usage).

P1 — Engine Registration (e47d50d)

  • Added EngineDescriptor trait and EngineRegistry GPUI global (connection/descriptor.rs)
  • Each engine exports a zero-size impl (PostgresEngine, SqliteEngine, MongoEngine)
  • main.rs registers them at startup — the only file to touch when adding a new engine

P2 — Panel Factory Decoupling (63e5261)

  • Each engine gains tab_dispatch::build_panel(spec, ...) -> Option<Arc<dyn PanelView>>
  • dispatch_open_tab shrinks from a 300-line match-of-matches to ~20 lines
  • Adding a new tab type for an existing engine now only touches that engine's tab_dispatch.rs

P3 — Typed QueryEditorInit (89c68f4)

  • TabSpec::QueryEditor now carries init: QueryEditorInit (Sql { sql, auto_run } | MongoPipeline { pipeline, collection }) instead of flat optional fields
  • Engine-specific init data no longer pollutes the shared TabSpec type

P4 — AuthMethod in based-core (3fd4b8b)

  • New crates/based-core/src/auth.rs: Password, SshTunnel { inner: Box<AuthMethod> }, AwsIam, ClientCertificate, External
  • Includes has_tunnel(), inner_auth(), label(), serde round-trips, and a migration path comment for moving per-engine auth fields here

P5 — EditorContext service (eebe5d5)

  • New apps/desktop/src/editor/ module: VariableScope, SchemaCache (with complete(prefix) for autocomplete), EditorContext GPUI entity
  • Foundation for LSP autocomplete, scoped variables, inline explain, and lint

P6 — TabScope + clean conn_id() (4173f92)

  • TabSpec::scope() -> TabScope returns Connection, MultiConnection, Workspace, or Global
  • conn_id() now returns Option<&ConnectionId> — removes the __home sentinel hack
  • Workspace-scoped tabs (ER diagrams, agent chat, charts) have a clean scope variant

Test plan

  • cargo check -p desktop passes with no errors
  • Existing tab open/close/session-restore flows work as before
  • New engine registration in main.rs compiles with just a registry.register(...) call
  • AuthMethod serde round-trip tests pass (cargo test -p based-core)

Made with Cursor

pavi2410 and others added 6 commits June 1, 2026 06:15
Introduces a registration pattern for database engine families.
Each engine exports a zero-size EngineDescriptor implementor; the
EngineRegistry global is populated at startup. Adding a new engine
family no longer requires touching central dispatch — only a new
register() call in main.rs and a new descriptor struct.

Purely additive: no existing behavior changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Each engine module now owns its panel-construction logic in
tab_dispatch::build_panel(). The central dispatch_open_tab becomes a
short delegating match with one arm per engine.

Adding a new tab type for an existing engine only requires editing that
engine's tab_dispatch.rs. Adding a new engine requires one match arm
plus a new tab_dispatch.rs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replaces flat, mixed-engine fields on TabSpec::QueryEditor with a
typed QueryEditorInit enum (Sql | MongoPipeline). Engine-specific init
data no longer pollutes the shared TabSpec type.

Session migration: load_tabs_with_migration() falls back to per-item
parsing so pre-P3 sessions lose only their QueryEditor tabs (not all
tabs) when the format doesn't match.

Co-authored-by: Cursor <cursoragent@cursor.com>
Introduces AuthMethod enum (Password, SshTunnel, AwsIam,
ClientCertificate, External) as a typed first-class auth abstraction.

Includes has_tunnel(), inner_auth(), and label() helpers.
Six unit tests cover default, SSH tunnel nesting, and serde round-trips.

Migration path to wire into ConnectionConfig is documented in auth.rs.
Purely additive — no existing code changed.

Co-authored-by: Cursor <cursoragent@cursor.com>
Introduces VariableScope, SchemaCache, and EditorContext types in
apps/desktop/src/editor/. Each SQL editor panel (Postgres, SQLite)
creates an EditorContext entity on construction.

EditorContext is the attachment point for future LSP clients, variable
autocomplete, schema-aware completion, and inline explain overlays —
none of those features require touching panel internals once wired here.

Co-authored-by: Cursor <cursoragent@cursor.com>
Introduces TabScope enum (Connection | MultiConnection | Workspace | Global)
for classifying tabs by their connection scope. Removes the
HOME_CONN_SENTINEL sentinel hack — TabSpec::conn_id() now cleanly
returns Option<&ConnectionId>.

Workspace-scoped tabs (future: ER diagrams, agent chat, chart builder)
and global tabs (Home, ReleaseNotes) are now first-class, not
sentinel-based hacks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 1, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
based d452dae Commit Preview URL

Branch Preview URL
Jun 01 2026, 05:48 PM

@pavi2410 pavi2410 self-assigned this Jun 1, 2026
@pavi2410
pavi2410 marked this pull request as ready for review June 1, 2026 04:58
@pavi2410
pavi2410 merged commit f27759d into main Jun 1, 2026
2 checks passed
@pavi2410
pavi2410 deleted the feat/architecture-extensibility branch June 1, 2026 20:49
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