Skip to content

Conversation

@zkat
Copy link
Contributor

@zkat zkat commented Aug 16, 2023

CodeMappers are a new language service feature that's designed to work as a deterministic aid to code generators like Copilot. The endpoint takes some arbitrary, generated code, some "focus locations" (generally things like cursor location, current selected method scope range, etc), and tries to "place" the AI-generated code in "the right place". While deterministic, it's fairly heuristic.

This version is able to also target "things that look like they match", like functions with the same name, or if statements with the same condition and actually replace their definitions/bodies, instead of appending them to the given scope.

The intention is to make it easier to go from asking an AI assistant like copilot "give me code to do this", to code that actually fits where it's supposed to. Having the language service do this lets us make more informed decisions than what a simple diff codemapper (the default) might be able to do.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 16, 2023
@typescript-bot
Copy link
Collaborator

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary.

@zkat zkat force-pushed the dev/kmarchan/code-mappers branch 6 times, most recently from cce4168 to 5db93cc Compare August 16, 2023 23:24
@fatcerberus
Copy link

putting this up to facilitate discussion

It would help if you explained what this even is.

@jakebailey
Copy link
Member

Kat is a team member, no need to be hasty 🙂

@zkat
Copy link
Contributor Author

zkat commented Aug 21, 2023

@fatcerberus sorry for the lack of clarity. We're working internally on a new codeaction-like feature, and I wanted to put up this PR to help coordinate between my team (the VS side, mainly, with some tsserver), and the VS Code team implementing this on their end. We'll have more details when more details are actually relevant to share :)

@zkat zkat force-pushed the dev/kmarchan/code-mappers branch 2 times, most recently from 0ff44a6 to 9bb8233 Compare August 22, 2023 19:08
@zkat zkat force-pushed the dev/kmarchan/code-mappers branch from 7c0d35c to 83442f8 Compare November 14, 2023 00:01
@zkat zkat force-pushed the dev/kmarchan/code-mappers branch from 83442f8 to 05c8862 Compare February 9, 2024 23:59
@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

@zkat zkat force-pushed the dev/kmarchan/code-mappers branch 4 times, most recently from d49995b to b92490c Compare February 15, 2024 00:13
@zkat zkat marked this pull request as ready for review February 15, 2024 00:13
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

disable synchronization for now

Update src/server/session.ts

Co-authored-by: Nathan Shively-Sanders <[email protected]>

Update src/services/mapCode.ts

Co-authored-by: Nathan Shively-Sanders <[email protected]>

Update src/services/mapCode.ts

Co-authored-by: Nathan Shively-Sanders <[email protected]>

Update src/services/mapCode.ts

Co-authored-by: Nathan Shively-Sanders <[email protected]>

format

some review changes

more review fixes

review

more passing tests

rejigger how class member replacement works to match statements algo

starting baseline-based mapcode tests

baseline-based tests

review

bring back synchronizeHostData

syntax operation change

move to operating on one file at a time

Update src/server/protocol.ts

Co-authored-by: Sheetal Nandi <[email protected]>

Update src/server/protocol.ts

Co-authored-by: Sheetal Nandi <[email protected]>

Update src/server/protocol.ts

Co-authored-by: Sheetal Nandi <[email protected]>

Update src/server/protocol.ts

Co-authored-by: Sheetal Nandi <[email protected]>

Update src/server/protocol.ts

Co-authored-by: Sheetal Nandi <[email protected]>

Update src/server/session.ts

Co-authored-by: Sheetal Nandi <[email protected]>

Update src/server/session.ts

Co-authored-by: Sheetal Nandi <[email protected]>

Update src/services/mapCode.ts

Co-authored-by: Sheetal Nandi <[email protected]>

Update src/services/types.ts

Co-authored-by: Sheetal Nandi <[email protected]>

Update src/services/mapCode.ts

Co-authored-by: Sheetal Nandi <[email protected]>

more review fixes
@zkat zkat force-pushed the dev/kmarchan/code-mappers branch from 714e82b to 4925fe9 Compare May 13, 2024 23:56
@zkat zkat requested a review from sheetalkamat May 14, 2024 16:34
Copy link
Member

@sheetalkamat sheetalkamat left a comment

Choose a reason for hiding this comment

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

We recommend that PRs should squash commits after requesting review. Please add more commits instead of squashing as it becomes difficult to track history. We merge PR as a squash commit so it wont affect the merge commit. But squashing commits between reviews makes it difficult to review.

@zkat zkat force-pushed the dev/kmarchan/code-mappers branch from 58eeb9e to 054ce2d Compare May 21, 2024 21:46
@zkat zkat requested a review from sheetalkamat May 21, 2024 22:30
@zkat zkat requested a review from sheetalkamat May 22, 2024 21:08
@zkat zkat requested a review from sheetalkamat May 22, 2024 22:07
@zkat zkat merged commit ddf43cd into microsoft:main May 22, 2024
@zkat zkat deleted the dev/kmarchan/code-mappers branch May 22, 2024 23:47
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants