Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment with threading AI into extraction refactorings #182779

Closed
DanielRosenwasser opened this issue May 17, 2023 · 6 comments
Closed

Experiment with threading AI into extraction refactorings #182779

DanielRosenwasser opened this issue May 17, 2023 · 6 comments
Assignees
Labels
exploration typescript Typescript support issues
Milestone

Comments

@DanielRosenwasser
Copy link
Member

Today, TSServer provides several actions for "extract to function" and "extract to local" for both TypeScript and JavaScript. Currently, TSServer just creates a pre-generated name like newLocal or newFunction that's sufficiently unique. While this is fine, it would be interesting if we could use a language model to come up with a useful name and calculate a better name while TypeScript itself calculates the refactoring.

In cases where a language model can "confidently" calculate a new name, that name can replace the contents of the automatically-invoked rename for the refactor.

@spartanatreyu
Copy link

This should be controlled by a setting for sure.

Here are the outcomes I can see with this feature:

  • A user refactors some code, likes the AI generated name and decides to use it.
  • A user refactors some code and sees the AI generated name, but they want to make a slight tweak to the name.
  • A user reactors some code and doesn't want to use the AI generated names at all.
    • Perhaps the user is consistently getting bad suggestions for the particular thing they are trying to do.
    • Perhaps seeing pre-generated names like newLocal or newFunction is a part of their proofing workflow (with eyeballs, linters, git hooks, or other code analysis tools).
    • The user is against using AI for some other reason

@mjbvz mjbvz added the feature-request Request for new features or functionality label May 25, 2023
@zardoy
Copy link
Contributor

zardoy commented Jun 1, 2023

I think TypeScript should try to infer name using common naming conventions at least (such as use... or get...), just like vscode-postfix-ts extension does:

From my experience it covers ~20% of code and can be useful if AI suggestions are slow, unavailable or a user doesn't want to use the AI generated names at all.

@robbiespeed
Copy link

Why not instead expose this through an API? So it's not tied to a single technology. It would allow valuable customization to make sure the name conforms to project guidelines, or takes into account various patterns from a given framework. In some cases even allow the name to be inferred statically by the content without AI.

@so1ve
Copy link

so1ve commented Jan 6, 2024

rust-analyzer has a suggest_name utility: https://github.com/rust-lang/rust-analyzer/blob/426d2842c1f0e5cc5e34bb37c7ac3ee0945f9746/crates/ide-assists/src/utils/suggest_name.rs

@mjbvz mjbvz modified the milestones: December / January 2024, February 2024 Jan 22, 2024
@mjbvz mjbvz modified the milestones: February 2024, March 2024 Feb 21, 2024
@mjbvz mjbvz modified the milestones: March 2024, April 2024 Mar 25, 2024
@mjbvz mjbvz modified the milestones: April 2024, May 2024 Apr 22, 2024
@mjbvz mjbvz modified the milestones: May 2024, June 2024 May 24, 2024
@Yoyokrazy Yoyokrazy added the verification-needed Verification of issue is requested label Jun 25, 2024
@amunger
Copy link
Contributor

amunger commented Jun 25, 2024

@DanielRosenwasser - is this the newly added behavior?

image

@amunger amunger added the verification-steps-needed Steps to verify are needed for verification label Jun 25, 2024
@mjbvz mjbvz added exploration and removed feature-request Request for new features or functionality labels Jun 26, 2024
@mjbvz
Copy link
Collaborator

mjbvz commented Jun 26, 2024

Marking this as an exploration. We'll create test items for the individual features that came out of it

@Yoyokrazy Yoyokrazy removed verification-needed Verification of issue is requested verification-steps-needed Steps to verify are needed for verification labels Jun 26, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exploration typescript Typescript support issues
Projects
None yet
Development

No branches or pull requests

8 participants