Add model selector to plan messages proceed button

This commit is contained in:
cto-new[bot]
2026-02-10 10:17:27 +00:00
parent 35b8084032
commit 7221361ae1
3 changed files with 221 additions and 2 deletions

View File

@@ -0,0 +1,72 @@
# Model Selector for Plan Messages Implementation
## Summary
When the "Proceed with Build" button appears in plan messages, a model selector dropdown is now displayed above it, allowing users to choose the AI model they want to use for the build process.
## Changes Made
### 1. New Helper Function: `createInlineModelSelector()`
**Location:** `chat/public/builder.js` (lines ~1899-1975)
Created a new helper function that generates an inline model selector specifically for plan messages:
- Creates a labeled select dropdown with the title "Select Model for Build:"
- Populates the dropdown with all available models from `state.models`
- Shows model labels, names, and multiplier indicators (e.g., "2x")
- Pre-selects the currently selected model from `state.selectedModelId`
- Handles model selection changes and updates:
- The inline selector's value
- The main model selector in the composer area
- The state's selectedModelId
- Marks the change as user-initiated to prevent server overwrites
### 2. Modified "Proceed with Build" Button Section
**Location:** `chat/public/builder.js` (lines ~2174-2193)
Updated the code where the "Proceed with Build" button is created:
- Creates a container div (`buildActionsContainer`) to hold both the model selector and the button
- Adds the inline model selector above the button
- Maintains the existing "Proceed with Build" button functionality
- Uses flexbox layout with proper spacing (gap: 12px, margin-top: 16px)
## How It Works
1. **Plan Message Displayed**: When an AI plan message is received and ready for building
2. **Model Selector Created**: The `createInlineModelSelector()` function is called to generate the dropdown
3. **User Selection**: User can select a different model for the build if desired
4. **State Sync**: Selection changes are synchronized with the main model selector
5. **Build Process**: When "Proceed with Build" is clicked, the selected model is used for the build
## Benefits
- **Better UX**: Users can now choose their model right where they need it (in the plan message)
- **Flexibility**: No need to go back to the composer area to change models before proceeding
- **Clear Context**: Model selector is clearly labeled as "Select Model for Build:"
- **State Consistency**: Model selection is synchronized across all UI elements
- **Prevents Conflicts**: User model selections are protected from server overwrites
## Technical Details
### Styling
The inline model selector uses:
- Consistent styling with the rest of the UI
- Custom SVG dropdown arrow
- Proper padding and borders matching the design system
- Full-width layout for easy selection on all devices
### State Management
- Updates `state.selectedModelId` when changed
- Calls `markUserModelChange()` to prevent server overwrites
- Syncs with the main model selector in the composer
- Preserves existing state management patterns
### Integration
- Works with the existing `updateModelSelectDisplay()` function
- Compatible with `markUserModelChange()` for state protection
- Integrates seamlessly with the current build flow
- No changes to backend or API required
## Testing
- JavaScript syntax check: ✓ Passed
- Function definition: ✓ Present at line 1900
- Function call: ✓ Present at line 2181
- No breaking changes to existing functionality