Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions web/src/app/chat/components/input/ActionManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ function MCPToolsList({
? disabledToolIds.filter((id) => id !== toolId)
: [...disabledToolIds, toolId],
});

// If we're disabling a tool that is currently forced, remove it from forced tools
if (!disabled && forcedToolIds.includes(toolId)) {
setForcedToolIds(forcedToolIds.filter((id) => id !== toolId));
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Sep 23, 2025

Choose a reason for hiding this comment

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

Use functional state update to avoid stale state when deriving next value from previous (setForcedToolIds should use prev => prev.filter(...)).

Prompt for AI agents
Address the following comment on web/src/app/chat/components/input/ActionManagement.tsx at line 274:

<comment>Use functional state update to avoid stale state when deriving next value from previous (setForcedToolIds should use prev =&gt; prev.filter(...)).</comment>

<file context>
@@ -268,6 +268,11 @@ function MCPToolsList({
+
+    // If we&#39;re disabling a tool that is currently forced, remove it from forced tools
+    if (!disabled &amp;&amp; forcedToolIds.includes(toolId)) {
+      setForcedToolIds(forcedToolIds.filter((id) =&gt; id !== toolId));
+    }
   };
</file context>
Suggested change
setForcedToolIds(forcedToolIds.filter((id) => id !== toolId));
setForcedToolIds((prev) => prev.filter((id) => id !== toolId));
Fix with Cubic

}
};

const toggleForcedTool = (toolId: number) => {
Expand Down Expand Up @@ -427,6 +432,11 @@ export function ActionToggle({ selectedAssistant }: ActionToggleProps) {
? disabledToolIds.filter((id) => id !== toolId)
: [...disabledToolIds, toolId],
});

// If we're disabling a tool that is currently forced, remove it from forced tools
if (!disabled && forcedToolIds.includes(toolId)) {
setForcedToolIds(forcedToolIds.filter((id) => id !== toolId));
}
};

const toggleForcedTool = (toolId: number) => {
Expand Down
Loading