-
Notifications
You must be signed in to change notification settings - Fork 619
Add chat context controls to playground #7999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add chat context controls to playground #7999
Conversation
This commit introduces the ability to specify whether transactions should be automatically executed within the Nebula context. This provides more control over the AI's interaction with the blockchain. Co-authored-by: joaquim.verges <joaquim.verges@gmail.com>
|
Cursor Agent can help with this pull request. Just |
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAPI and UI changes add an auto-execute flag to Nebula context, expose user-editable wallet/chain/auto-execute controls in the chat UI, and adjust the API payload to rename Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant UI as ChatPageContent
participant Ctx as NebulaContext (derived)
participant API as chat.ts
participant Neb as Nebula Server
U->>UI: Enter wallet, chain IDs, toggle auto-execute
UI->>UI: derive Ctx { walletAddress, chainIds, autoExecuteTransactions }
U->>UI: Submit prompt
UI->>API: sendPrompt(prompt, Ctx)
API->>API: build body.context with `from` = Ctx.walletAddress and `auto_execute_transactions` = Ctx.autoExecuteTransactions || false
API->>Neb: POST /chat with body.context
Neb-->>API: Response
API-->>UI: Result
UI-->>U: Display reply
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
✨ Finishing Touches
🧪 Generate unit tests
Comment |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7999 +/- ##
=======================================
Coverage 56.63% 56.64%
=======================================
Files 904 904
Lines 58677 58677
Branches 4161 4164 +3
=======================================
+ Hits 33231 33236 +5
+ Misses 25340 25335 -5
Partials 106 106
🚀 New features to boost your workflow:
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
apps/playground-web/src/app/ai/api/types.ts (1)
37-37: Make the flag non-optional to simplify downstream handling.Given we always coalesce to a boolean in the payload, consider making this required with a default of
falseat construction sites to avoid extraundefinedchecks across the codebase.- autoExecuteTransactions?: boolean; + autoExecuteTransactions: boolean;apps/playground-web/src/app/ai/api/chat.ts (1)
25-27: Prefer nullish coalescing and omit nullish fields in the payload.Use
??for boolean defaulting and avoid sendingnullforwallet_address(omit instead), which tends to be cleaner for APIs.- wallet_address: params.context.walletAddress, - auto_execute_transactions: params.context.autoExecuteTransactions || false, + wallet_address: params.context.walletAddress ?? undefined, + auto_execute_transactions: params.context.autoExecuteTransactions ?? false,apps/playground-web/src/app/ai/components/ChatPageContent.tsx (3)
71-76: Harden chain ID parsing and de‑duplicate entries.Only allow digits, support comma/space separators, and remove duplicates to avoid accidental duplicates or formats like
1e3.- const userChainIdArray = userChainIds - .split(',') - .map(id => id.trim()) - .filter(id => id !== '' && !isNaN(Number(id))); + const userChainIdArray = Array.from( + new Set( + userChainIds + .split(/[,\s]+/) + .map((id) => id.trim()) + .filter((id) => /^\d+$/.test(id)), + ), + );
125-129: Prefill the options bar from current context for better UX.Initialize with existing address/chain IDs so users see the active values instead of blanks.
- const [userWalletAddress, setUserWalletAddress] = useState(""); - const [userChainIds, setUserChainIds] = useState(""); - const [userAutoExecute, setUserAutoExecute] = useState(false); + const [userWalletAddress, setUserWalletAddress] = useState(address || ""); + const [userChainIds, setUserChainIds] = useState( + (_contextFilters?.chainIds || []).join(", "), + ); + const [userAutoExecute, setUserAutoExecute] = useState(false);
739-796: Conform to design system: remove inline styles, add explicit return type.
- Use Tailwind width utilities instead of inline
style.- Add an explicit return type per the TypeScript guideline.
- Optionally, replace native inputs with
@/components/ui/inputand a design-system Checkbox/Switch (not shown here to keep the diff minimal).-function ContextOptionsBar(props: { +function ContextOptionsBar(props: { walletAddress: string; chainIds: string; autoExecute: boolean; onWalletAddressChange: (value: string) => void; onChainIdsChange: (value: string) => void; onAutoExecuteChange: (value: boolean) => void; -}) { +}): React.JSX.Element { return ( <div className="mb-4 rounded-lg border bg-card p-3"> <div className="flex flex-wrap items-center gap-4"> <div className="flex items-center gap-2"> <label htmlFor="wallet-address" className="text-sm font-medium text-muted-foreground"> Wallet Address: </label> <input id="wallet-address" type="text" value={props.walletAddress} onChange={(e) => props.onWalletAddressChange(e.target.value)} placeholder="0x..." - className="px-2 py-1 text-sm border border-border rounded focus:outline-none focus:ring-1 focus:ring-ring focus:border-ring bg-background" - style={{ width: "200px" }} + className="w-[200px] px-2 py-1 text-sm border border-border rounded focus:outline-none focus:ring-1 focus:ring-ring focus:border-ring bg-background" /> </div> <div className="flex items-center gap-2"> <label htmlFor="chain-ids" className="text-sm font-medium text-muted-foreground"> Chain IDs: </label> <input id="chain-ids" type="text" value={props.chainIds} onChange={(e) => props.onChainIdsChange(e.target.value)} placeholder="1, 8453" - className="px-2 py-1 text-sm border border-border rounded focus:outline-none focus:ring-1 focus:ring-ring focus:border-ring bg-background" - style={{ width: "100px" }} + className="w-[120px] px-2 py-1 text-sm border border-border rounded focus:outline-none focus:ring-1 focus:ring-ring focus:border-ring bg-background" /> </div>Follow-up (optional): swap the native
<input>s forInputfrom@/components/ui/inputand a DS Checkbox/Switch to fully align with the playground design system.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
apps/playground-web/src/app/ai/api/chat.ts(1 hunks)apps/playground-web/src/app/ai/api/types.ts(1 hunks)apps/playground-web/src/app/ai/components/ChatPageContent.tsx(5 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
apps/playground-web/src/app/ai/api/types.tsapps/playground-web/src/app/ai/api/chat.tsapps/playground-web/src/app/ai/components/ChatPageContent.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
apps/playground-web/src/app/ai/api/types.tsapps/playground-web/src/app/ai/api/chat.tsapps/playground-web/src/app/ai/components/ChatPageContent.tsx
apps/{dashboard,playground-web}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from@/components/ui/*(Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
UseNavLinkfor internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Usecn()from@/lib/utilsfor conditional class logic
Use design system tokens (e.g.,bg-card,border-border,text-muted-foreground)
Server Components (Node edge): Start files withimport "server-only";
Client Components (browser): Begin files with'use client';
Always callgetAuthToken()to retrieve JWT from cookies on server side
UseAuthorization: Bearerheader – never embed tokens in URLs
Return typed results (e.g.,Project[],User[]) – avoidany
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stablequeryKeysfor React Query cache hits
ConfigurestaleTime/cacheTimein React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never importposthog-jsin server components
Files:
apps/playground-web/src/app/ai/api/types.tsapps/playground-web/src/app/ai/api/chat.tsapps/playground-web/src/app/ai/components/ChatPageContent.tsx
**/types.ts
📄 CodeRabbit inference engine (AGENTS.md)
Provide and re‑use local type barrels in a
types.tsfile
Files:
apps/playground-web/src/app/ai/api/types.ts
🧬 Code graph analysis (1)
apps/playground-web/src/app/ai/components/ChatPageContent.tsx (1)
apps/playground-web/src/app/ai/api/types.ts (1)
NebulaContext(33-38)
Slack Thread
PR-Codex overview
This PR introduces enhancements to the
ChatPageContentcomponent, adding user-configurable options for wallet address, chain IDs, and auto-execution of transactions. It also implements a newContextOptionsBarcomponent to facilitate these configurations.Detailed summary
autoExecuteTransactionsproperty toNebulaSwapData.fromandauto_execute_transactions.ChatPageContent.ContextOptionsBarcomponent for user inputs (wallet address, chain IDs, auto-execute).ContextOptionsBarinto the chat interface, allowing real-time updates.Summary by CodeRabbit
New Features
Improvements