fix: recursive proxy in createGetDb for Drizzle chaining#95
Conversation
The previous proxy broke db.select().from(table) because each method returned a promise instead of a chainable query builder. The new proxy records the chain of property accesses and method calls, then replays them on the real DB when the result is awaited via .then().
✅ Deploy Preview for agent-native-fw ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
agent-native-calendar | a33ee6d | Commit Preview URL Branch Preview URL |
Mar 27 2026, 05:53 PM |
Use local state for title and description inputs, syncing from server only when the input is not focused. Polling-driven React Query invalidations were resetting the controlled input value mid-typing.
- Title input in top bar auto-grows/shrinks based on text length - Moved "+ New form" button under the forms list in sidebar - New form creation shows an agent prompt dialog where users can describe the form they want; Skip creates a blank form
Replaces the fixed overlay with a Popover anchored to the "+ New form" button. Matches the slides template design: bold title, borderless textarea, "Skip prompt" link + arrow submit button in footer.
Use MessageCircle icon instead of text button. Restyle the agent prompt popover to match the new form prompt: borderless textarea, bold title, arrow submit button in footer.
- TiptapComposer mention reference extensions and search - Agent chat plugin mention provider support - Production agent type updates for references - Template agent-chat plugin updates across all apps - Slides route and UI updates
There was a problem hiding this comment.
Forms sidebar redesign: compact nav with "New form" → Popover AI prompt → Skip option. Slides template loads without DB errors.
Details
Visual verification of PR #95 UI changes. Forms template loads correctly with the new compact sidebar. The "New form" Popover opens smoothly with AI prompt and "Skip prompt" fallback. Slides template loads without the db.select(...).from is not a function error (primary fix verified). The 404s seen in console are pre-existing unrelated issues (/api/env-status, /api/available-clis).
There was a problem hiding this comment.
Builder has reviewed your changes and found 2 potential issues.
Review Details
PR #95 — Code Review
This PR has grown significantly across multiple commits and now touches 23 files (834 additions). Core changes:
-
DB proxy fix (
create-get-db.ts) — Replaces the original single-level proxy that broke Drizzle's fluent chaining with a recursive proxy that records the full property/method chain and replays it on the real_dbonce init completes. -
Forms UI polish (
FormBuilderPage.tsx,Sidebar.tsx) — Buffers title/description in local state with focus-ref guards to prevent polling resets during typing; redesigns sidebar with compact layout and AI-powered "New form" Popover. -
Mentions system — Adds a unified
@-mention system aggregating codebase files, SQL resources, and per-template custom providers (forms, decks, bookings, emails). Wires through Tiptap (MentionReferenceextension) and the production agent handler.
Risk: Standard — Core DB infrastructure + new API endpoint + UI changes across multiple templates.
Visual verification: Forms template loads ✅, sidebar redesign renders correctly ✅, New form Popover opens and auto-focuses textarea ✅, slides template loads without the TypeError ✅.
Findings
🟡 MEDIUM — DB proxy apply trap crashes when chain is empty
chain[chain.length - 1] is undefined when the initial proxy (empty chain) is called as a function. The proxy wraps function () {}, so typeof proxy === 'function' is true — framework introspection or test code calling it directly will throw.
🟡 MEDIUM — Custom mention providers hidden by codebase files on initial @ load
Items are aggregated codebase-first, then resources, then custom providers. With an empty query, all items are collected unfiltered and sliced to 30. In a large repo (dev mode), custom provider items (forms, decks, etc.) may never appear in the initial dropdown. Consider per-source caps or interleaved ordering.
Code review by Builder.io
| ) | ||
| : items; | ||
|
|
||
| return { items: filtered.slice(0, 30) }; |
There was a problem hiding this comment.
🟡 Custom mention providers hidden by codebase files on initial load
When q is empty, codebase files (added first) can fill the 30-item cap before custom provider items (forms, decks, emails) are reached. Consider applying a per-source item cap (e.g. 10 codebase files) before the final slice(0, 30) so all provider types are represented in the initial @-mention dropdown.
How did I do? React with 👍 or 👎 to help me improve.
There was a problem hiding this comment.
This is in another agent's WIP changes to agent-chat-plugin.ts — not related to this PR's createGetDb changes.
Add mentionProviders to AgentChatPluginOptions so templates can register custom @-taggable item types. New unified /api/agent-chat/mentions endpoint merges files, resources, and custom provider results. New generalized MentionReference Tiptap extension renders chips with type-specific icons (document, form, email, deck, etc.). Template integrations: - Content: @-tag documents by title - Slides: @-tag decks by title - Forms: @-tag forms by title (with status) - Calendar: @-tag bookings and booking links - Mail: @-tag emails from inbox (subject + sender)
When an event is selected in the sidebar panel, pressing Delete or Backspace deletes it and clears the selection.
- Add intType() helper returning BIGINT for Postgres, INTEGER for SQLite - Use intType() in all core store CREATE TABLE statements - Add INTEGER->BIGINT rewrite in adaptSqlForPostgres for migrations - Extract calendar event color logic into shared module
- Mail: label alias system for renaming tab labels (labelAliases in settings) - Mail: switch db/index.ts to use core's createGetDb for Postgres support - Mail: inline rename UI in tab settings popover - Calendar: event detail panel and calendar view updates from parallel agents
Summary
db.select().from is not a functionerror during startup raceTest plan
pnpm run preppasses (build, typecheck, tests, format)TypeError: db.select(...).from is not a function🤖 Generated with Claude Code