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
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@ export function ToolSubBlockRenderer({
}, [toolParamValue, setStoreValue, isObjectType])

useEffect(() => {
if (storeValue == null) return
const stringValue = typeof storeValue === 'string' ? storeValue : JSON.stringify(storeValue)
if (storeValue == null && lastPushedToParamsRef.current === null) return
const stringValue =
storeValue == null
? ''
: typeof storeValue === 'string'
? storeValue
: JSON.stringify(storeValue)
Copy link

Choose a reason for hiding this comment

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

Initial mount briefly clears existing tool param values

Medium Severity

On initial mount with existing non-empty tool params, the second useEffect incorrectly clears the param to ''. The first effect runs and sets lastPushedToParamsRef.current to the existing param value (e.g. "hello") via a synchronous ref mutation. The second effect then sees storeValue still as null (stale from the current render) but lastPushedToParamsRef.current is no longer null, so the guard on line 81 doesn't return early. It converts null to '' and pushes that to params via onParamChange. The value self-corrects on the next render cycle, but this creates an unnecessary clear-then-restore round-trip and extra re-renders.

Fix in Cursor Fix in Web

if (stringValue !== lastPushedToParamsRef.current) {
lastPushedToParamsRef.current = stringValue
lastPushedToStoreRef.current = stringValue
Expand Down