Table of Contents
Fetching ...

Smart Paste: Automatically Fixing Copy/Paste for Google Developers

Vincent Nguyen, Guilherme Herzog, José Cambronero, Marcus Revaj, Aditya Kini, Alexander Frömmgen, Maxim Tabachnyk

TL;DR

This work presents Smart Paste, an in-IDE feature that automatically suggests edits to pasted code to fit surrounding context, addressing both high-quality, context-aware fixes and enterprise-scale deployment. It introduces a data collection pipeline based on real paste-edit logs, a unified small transformer model fine-tuned on multilingual Google code, and a low-latency inference architecture with a robust inline-diff UI. The results show 45% acceptance, substantial keystroke savings (≈22 per accepted paste), and over 1% of company-wide code affected, validating production viability across multiple languages and surfaces. The study offers a holistic blueprint for developing AI-powered coding assistants, including data curation, model design, latency-aware serving, and user experience considerations that can guide practitioners in similar industrial settings.

Abstract

Manually editing pasted code is a long-standing developer pain point. In internal software development at Google, we observe that code is pasted 4 times more often than it is manually typed. These paste actions frequently require follow-up edits, ranging from simple reformatting and renaming to more complex style adjustments and cross-language translations. Prior work has shown deep learning can be used to predict these edits. In this work, we show how to iteratively develop and scale Smart Paste, an IDE feature for post-paste edit suggestions, to Google's development environment. This experience can serve as a guide for AI practitioners on a holistic approach to feature development, covering user experience, system integration, and model capabilities. Since deployment, Smart Paste has had overwhelmingly positive feedback with a 45% acceptance rate. At Google's enterprise scale, these accepted suggestions account substantially for over 1% of all code written company-wide.

Smart Paste: Automatically Fixing Copy/Paste for Google Developers

TL;DR

This work presents Smart Paste, an in-IDE feature that automatically suggests edits to pasted code to fit surrounding context, addressing both high-quality, context-aware fixes and enterprise-scale deployment. It introduces a data collection pipeline based on real paste-edit logs, a unified small transformer model fine-tuned on multilingual Google code, and a low-latency inference architecture with a robust inline-diff UI. The results show 45% acceptance, substantial keystroke savings (≈22 per accepted paste), and over 1% of company-wide code affected, validating production viability across multiple languages and surfaces. The study offers a holistic blueprint for developing AI-powered coding assistants, including data curation, model design, latency-aware serving, and user experience considerations that can guide practitioners in similar industrial settings.

Abstract

Manually editing pasted code is a long-standing developer pain point. In internal software development at Google, we observe that code is pasted 4 times more often than it is manually typed. These paste actions frequently require follow-up edits, ranging from simple reformatting and renaming to more complex style adjustments and cross-language translations. Prior work has shown deep learning can be used to predict these edits. In this work, we show how to iteratively develop and scale Smart Paste, an IDE feature for post-paste edit suggestions, to Google's development environment. This experience can serve as a guide for AI practitioners on a holistic approach to feature development, covering user experience, system integration, and model capabilities. Since deployment, Smart Paste has had overwhelmingly positive feedback with a 45% acceptance rate. At Google's enterprise scale, these accepted suggestions account substantially for over 1% of all code written company-wide.

Paper Structure

This paper contains 27 sections, 11 figures, 5 tables, 1 algorithm.

Figures (11)

  • Figure 1: Smart Paste monitors a developer's IDE activity, so that when a paste takes place it can render (inline) suggested edits to adapt it to the current context.
  • Figure 2: A developer's coding journey, reconstructed from File Snapshot and Edit Delta events. Our method identifies a Paste Start and tracks related edits to find the final Paste End state. The goal of Smart Paste is to predict this final state given only the initial paste.
  • Figure 3: Task representation for the Smart Paste model using the example from Figure \ref{['fig:edit-session']} -- the output unidiff format allows us to represent edit suggestions and no-edit suggestions (not shown) in the same way.
  • Figure 4: Our user interface renders suggestions as an inline diff with yellow highlighting. This design allows for easy review, which is critical for building the developer trust needed to drive feature adoption.
  • Figure 5: The "auto-apply with hint" design automatically applied suggestions, but this intrusive nature eroded user trust and disrupted developer flow, especially when incorrect.
  • ...and 6 more figures