Skip to content

Commit c82704d

Browse files
committed
fix(user-input): always update prevDefaultValueRef on defaultValue change
Prevents stale ref when defaultValue transitions through empty — if defaultValue goes non-empty → empty → same non-empty value, the ref was not updated on the empty transition, causing setValue to be skipped on the subsequent change. Also removes unnecessary useCallback wrapping from handleSendQueuedHead, handleEditQueued, handleEditQueuedTail in MothershipChat — none have a reference observer (UserInput stores them via refs, QueuedMessages is not React.memo-wrapped).
1 parent c43aca2 commit c82704d

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/home/components/user-input

apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,9 @@ export const UserInput = forwardRef<UserInputHandle, UserInputProps>(function Us
152152

153153
const prevDefaultValueRef = useRef(defaultValue)
154154
useEffect(() => {
155-
if (!defaultValue) return
156155
if (defaultValue === prevDefaultValueRef.current) return
157156
prevDefaultValueRef.current = defaultValue
158-
setValue(defaultValue)
157+
if (defaultValue) setValue(defaultValue)
159158
}, [defaultValue])
160159

161160
const files = useFileAttachments({

0 commit comments

Comments
 (0)