Skip to content

Conversation

dancer
Copy link
Collaborator

@dancer dancer commented Sep 18, 2025

background

the v5 migration removes managed input state from the usechat hook. users need to manually manage input state with usestate instead of relying on the built-in input and handleinputchange from usechat. without this codemod, users would need to manually update every usechat usage in their codebase

summary

  • added codemod to transform usechat destructuring patterns
  • removes input and handleinputchange from usechat
  • adds usestate for local input management
  • replaces handleinputchange with inline setters

verification

tested with real-world patterns including aliased destructuring, partial extraction, and function-scoped replacements. all tests pass

tasks

  • created replace-usechat-input-with-state codemod
  • handled import alias preservation
  • added function-scoped identifier replacement
  • created test fixtures for all edge cases
  • integrated into v5 upgrade bundle

@gr2m gr2m added the backport label Sep 18, 2025
@gr2m gr2m merged commit 740d4bf into main Sep 26, 2025
11 checks passed
@gr2m gr2m deleted the josh/u branch September 26, 2025 22:32
vercel-ai-sdk bot pushed a commit that referenced this pull request Sep 26, 2025
## background

the v5 migration removes managed input state from the usechat hook.
users need to manually manage input state with usestate instead of
relying on the built-in input and handleinputchange from usechat.
without this codemod, users would need to manually update every usechat
usage in their codebase

## summary

- added codemod to transform usechat destructuring patterns
- removes input and handleinputchange from usechat
- adds usestate for local input management
- replaces handleinputchange with inline setters

## verification

tested with real-world patterns including aliased destructuring, partial
extraction, and function-scoped replacements. all tests pass

## tasks

- [x] created replace-usechat-input-with-state codemod
- [x] handled import alias preservation
- [x] added function-scoped identifier replacement
- [x] created test fixtures for all edge cases
- [x] integrated into v5 upgrade bundle

---------

Co-authored-by: Gregor Martynus <[email protected]>
@vercel-ai-sdk vercel-ai-sdk bot removed the backport label Sep 26, 2025
@vercel-ai-sdk
Copy link
Contributor

vercel-ai-sdk bot commented Sep 26, 2025

✅ Backport PR created: #8970

gr2m added a commit that referenced this pull request Sep 26, 2025
#8970)

This is an automated backport of #8725 to the release-v5.0 branch.

Co-authored-by: josh <[email protected]>
Co-authored-by: Gregor Martynus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants