Conversation
- Add 6 new dashboard pages for IaC features: - IaC Schema Viewer: View tables, columns, indexes - IaC Functions Dashboard: List queries, mutations, actions - Scheduled Jobs: Manage cron jobs from bbf/cron.ts - Realtime Connections: Monitor WebSocket connections - SQL Query Runner: Execute raw SELECT queries - Add IaC routes in server package - Add test suite for IaC API routes (10 tests) - Simplify README.md and CODEBASE_MAP.md - Add IaC documentation (docs/iac/) BREAKING CHANGE: Dashboard routes moved under /projects/:id/iac/
…template - Made bb init use BetterBase template as default (instead of requiring --iac flag) - Renamed BBF folder to BetterBase across the entire codebase - Updated all references from bbf/ to betterbase/ in CLI, server, core, client packages - Updated test files to use BetterBase naming
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (93)
📝 WalkthroughWalkthroughA comprehensive PR implementing BetterBase Phase 3 IaC specification with 30 ordered tasks: adds optimistic mutations, raw SQL/analyze APIs, PostgreSQL full-text search and pgvector similarity, query diagnostics, data portability tooling, improved error handling, Convex migration CLI, dev-mode query logging, and extensive IaC documentation for schema definition, functions, client hooks, storage, scheduler, modules, realtime, and optimization guidance. Changes
Sequence DiagramssequenceDiagram
participant Client
participant Server as Server<br/>(Function Handler)
participant Database as Database<br/>(PostgreSQL)
participant WSBroadcaster as WebSocket<br/>(Invalidation)
Client->>Client: Call mutation<br/>(with optimistic data)
Client->>Server: POST /betterbase/mutations/*<br/>{args}
activate Server
Server->>Database: BEGIN TRANSACTION
Server->>Database: INSERT/UPDATE/DELETE
Database->>Server: Success
Server->>Database: COMMIT
Server->>WSBroadcaster: Emit invalidate<br/>(table changes)
Server->>Client: {result: ...}
deactivate Server
Client->>Client: Replace optimistic<br/>with real result
WSBroadcaster->>Client: {type: invalidate,<br/>tables: [...]}
Client->>Client: Refetch subscribed<br/>queries
sequenceDiagram
participant Client
participant Server as Server<br/>(Schema Analyzer)
participant Database as Database<br/>(EXPLAIN ANALYZE)
Client->>Server: POST /betterbase/queries/*<br/>{sql, params}
activate Server
Server->>Server: Sanitize SQL<br/>(SELECT only)
Server->>Database: EXECUTE query
Database->>Server: {rows, columns}
Server->>Client: {columns, rows, row_count}
deactivate Server
Client->>Server: ctx.db.analyze(query)
activate Server
Server->>Database: EXPLAIN ANALYZE
Database->>Server: Plan + cost info
Server->>Server: Parse plan,<br/>extract cost/indexes
Server->>Client: {plan, estimatedCost,<br/>suggestedIndexes, isSlow}
deactivate Server
sequenceDiagram
participant Client
participant WSServer as WebSocket<br/>Server
participant SubTracker as Subscription<br/>Tracker
participant InvalidMgr as Invalidation<br/>Manager
Client->>WSServer: Connect<br/>(/betterbase/ws)
activate WSServer
WSServer->>Client: {type: connected,<br/>clientId}
deactivate WSServer
Client->>WSServer: {type: subscribe,<br/>path, args}
activate WSServer
WSServer->>SubTracker: Register subscription
WSServer->>Client: {type: subscribed}
deactivate WSServer
Note over InvalidMgr: Table mutation occurs
InvalidMgr->>SubTracker: Get subscriptions<br/>for affected tables
SubTracker->>InvalidMgr: [{clientId, path, args}]
InvalidMgr->>WSServer: Push invalidate msg
WSServer->>Client: {type: invalidate,<br/>tables, functionPath}
Client->>Client: Refetch query
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
✨ Finishing Touches🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
💡 Codex Review
Betterbase/packages/server/src/index.ts
Lines 80 to 83 in 3a62daa
The server entrypoint exports only { port, fetch }, so Bun never receives a websocket handler or upgrade hook for /betterbase/ws (implemented separately in routes/betterbase/ws.ts). This leaves realtime subscriptions unreachable in runtime even though clients always attempt to connect to that websocket endpoint.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| mutateAsync(args).catch(() => {}); // fire-and-forget variant | ||
| return mutateAsync(args); |
There was a problem hiding this comment.
Call mutateAsync only once per mutate invocation
mutate currently invokes mutateAsync(args) twice (once fire-and-forget and once returned), so every mutation sends two HTTP requests and can apply side effects twice. This is especially harmful for non-idempotent writes (e.g., inserts/payments) and will also duplicate optimistic state transitions.
Useful? React with 👍 / 👎.
| headers: { | ||
| "Content-Type": "application/json", | ||
| ...(token ? { Authorization: `Bearer ${token}` } : {}), | ||
| }, |
There was a problem hiding this comment.
Send project slug header in IaC HTTP calls
The client request helper does not include X-Project-Slug, but the server resolves schema from that header (packages/server/src/routes/betterbase/index.ts, projectSlug = c.req.header("X-Project-Slug") ?? "default"). As a result, multi-project apps will execute all function calls against project_default instead of the configured project, causing cross-project reads/writes.
Useful? React with 👍 / 👎.
| "DROP", | ||
| "TRUNCATE", | ||
| "DELETE", | ||
| "INSERT", | ||
| "UPDATE", |
There was a problem hiding this comment.
Allow write statements in writer SQL sanitizer
The shared sanitizer still marks DELETE, INSERT, and UPDATE as forbidden, but DatabaseWriter.execute() advertises write support and calls this sanitizer. In practice, writer raw SQL writes always throw before execution, breaking documented mutation-side ctx.db.execute(...) workflows.
Useful? React with 👍 / 👎.
Summary by CodeRabbit
Release Notes
New Features
Documentation