Skip to content

fix: recursive proxy in createGetDb for Drizzle chaining#95

Merged
steve8708 merged 11 commits intomainfrom
updates-39
Mar 27, 2026
Merged

fix: recursive proxy in createGetDb for Drizzle chaining#95
steve8708 merged 11 commits intomainfrom
updates-39

Conversation

@steve8708
Copy link
Copy Markdown
Contributor

Summary

Test plan

  • pnpm run prep passes (build, typecheck, tests, format)
  • Verify slides template no longer throws TypeError: db.select(...).from is not a function

🤖 Generated with Claude Code

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().
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 27, 2026

Deploy Preview for agent-native-fw ready!

Name Link
🔨 Latest commit a33ee6d
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-fw/deploys/69c6c3852b272500087ac67e
😎 Deploy Preview https://deploy-preview-95--agent-native-fw.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 27, 2026

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
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
Copy link
Copy Markdown

@builder-io-integration builder-io-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visual Verification

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).


View in Builder.io

Copy link
Copy Markdown

@builder-io-integration builder-io-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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 _db once init completes.

  2. 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.

  3. Mentions system — Adds a unified @-mention system aggregating codebase files, SQL resources, and per-template custom providers (forms, decks, bookings, emails). Wires through Tiptap (MentionReference extension) 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.


View in Builder.io

Code review by Builder.io

)
: items;

return { items: filtered.slice(0, 30) };
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@steve8708 steve8708 merged commit b3d549d into main Mar 27, 2026
14 of 15 checks passed
@steve8708 steve8708 deleted the updates-39 branch March 27, 2026 18:32
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