Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(ui): move the New Agent effort during render so Create never sends one the menu dropped (#3133)

Call White7e487e527581
diff --git a/ui/eslint-baseline.json b/ui/eslint-baseline.json
index 42a5e8ef6..8888a2d69 100644
--- a/ui/eslint-baseline.json
+++ b/ui/eslint-baseline.json
@@ -458,7 +458,7 @@
"avibe/localized-user-text": 4
},
"src/components/workbench/NewAgentDialog.tsx": {
- "react-hooks/set-state-in-effect": 3
+ "react-hooks/set-state-in-effect": 2
},
"src/components/workbench/NewProjectDialog.tsx": {
"avibe/localized-user-text": 2
diff --git a/ui/src/components/workbench/NewAgentDialog.test.tsx b/ui/src/components/workbench/NewAgentDialog.test.tsx
index a91013350..eaffb59ba 100644
--- a/ui/src/components/workbench/NewAgentDialog.test.tsx
+++ b/ui/src/components/workbench/NewAgentDialog.test.tsx
@@ -288,8 +288,10 @@ describe('NewAgentDialog', () => {
await waitFor(() => expect(screen.getByText('agents.create.effortRefused:{"effort":"high"}')).toBeTruthy());
expect(createVibeAgent).not.toHaveBeenCalled();
- // The menu now follows that answer, so the effort moved to one it offers.
+ // The menu now follows that answer, and the effort moved with it to one it
+ // offers, so the Create that takes clicks again sends that one.
expect(screen.queryByRole('button', { name: 'high', exact: true })).toBeNull();
+ expect(screen.getByRole('button', { name: 'medium', exact: true }).className).toContain('bg-mint-soft');
// The refused Create has settled when its button takes clicks again.
const create = screen.getByRole('button', { name: /agents\.create\.submit/ }) as HTMLButtonElement;
await waitFor(() => expect(create.disabled).toBe(false));
diff --git a/ui/src/components/workbench/NewAgentDialog.tsx b/ui/src/components/workbench/NewAgentDialog.tsx
index 4246935eb..7ede88cdc 100644
--- a/ui/src/components/workbench/NewAgentDialog.tsx
+++ b/ui/src/components/workbench/NewAgentDialog.tsx
@@ -130,16 +130,15 @@ export const NewAgentDialog: React.FC<NewAgentDialogProps> = ({ open, onClose, o
// Keep the chosen effort valid as backend/model (and thus the option list)
// change, so handleSubmit never sends an effort the backend would reject
- // (e.g. picking Codex `xhigh` then switching to Claude).
- useEffect(() => {
- if (effortOptions.length === 0) {
- setEffort(null);
- return;
- }
- if (effort === null || !effortOptions.includes(effort)) {
- setEffort(effortOptions.includes('medium') ? 'medium' : effortOptions[0]);
- }
- }, [effortOptions, effort]);
+ // (e.g. picking Codex `xhigh` then switching to Claude). It moves during
+ // render, not in an effect: an effect runs after the new menu is committed,
+ // and Create, enabled in that commit, would send the effort the menu dropped.
+ const offeredEffort = effortOptions.length === 0
+ ? null
+ : effort !== null && effortOptions.includes(effort)
+ ? effort
+ : effortOptions.includes('medium') ? 'medium' : effortOptions[0];
+ if (offeredEffort !== effort) setEffort(offeredEffort);
const canSubmit = name.trim().length > 0 && !submitting && catalogAnswered;