perf: defer AI chat tool handler imports#35
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4388b2e9f0
ℹ️ 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".
|
|
||
| try { | ||
| let result: unknown | ||
| const handlers = await getToolHandlers() |
There was a problem hiding this comment.
Avoid gating all tool calls on lazy handler chunk load
The new unconditional await getToolHandlers() runs before the switch, so even runBackgroundDiagram (which does not use @/lib/ai-chat/tool-handlers) now fails if the lazy chunk cannot be fetched (e.g., stale client after deploy or transient chunk-load/network error). In that scenario, execution jumps to the outer catch and returns an error instead of running the background-diagram path, which is a behavior regression introduced by this commit.
Useful? React with 👍 / 👎.
4388b2e to
3211550
Compare
Summary
@/lib/ai-chat/tool-handlersuntil first tool callValidation
pnpm buildCloses #23
Note
Low Risk
Change is isolated to import timing/caching in the chat UI; functional behavior should remain the same aside from potential first-call load latency or dynamic import failures.
Overview
Defers loading of
@/lib/ai-chat/tool-handlersinAIChatPanelby removing static imports and dynamically importing the module on the first tool call.Caches the imported handlers in a ref (
getToolHandlers) and routes all tool executions through the cached module, preserving the existing tool-call switch behavior (including asyncplaceImage).Written by Cursor Bugbot for commit 3211550. This will update automatically on new commits. Configure here.