Transferring a GitHub Copilot Session to Visual Studio Code
The GitHub Copilot app allows users to continue their sessions directly in Visual Studio Code, enabling them to inspect implementation details, make adjustments, and run projects locally without starting over.
To transition from the Copilot app to VS Code, users can open their session directly in the editor, preserving the conversation, code changes, and working context. This integration allows Copilot to handle repetitive tasks while users focus on detailed reviews and local testing.
This tutorial covers the following steps:
- Opening a Copilot app session in VS Code.
- Reviewing the agent’s changes line by line.
- Continuing the same conversation from the editor.
- Modifying and testing the code locally.
- Pushing updates to the associated pull request.
1. Start with a Session in the Copilot App
Open the session you wish to continue. Review the task and the work Copilot has completed. A session includes not only modified files but also the task, plan, and conversation that led to those changes, providing essential context.
2. Open the Session in VS Code
Select Open in VS Code from the session. If multiple editors or installations are available, choose the desired one. VS Code will open the project using the worktree associated with the session and display the existing session in the Copilot sidebar.
This setup provides three connected elements:
- The session context: The task, plan, and conversation are accessible.
- The diff: Files and lines changed by the agent are ready for review.
- The worktree: VS Code opens the same isolated working tree used in the session.
3. Review the Agent’s Changes
Inspect the diff in VS Code before making edits. Open the Source Control view to see changed files, then select a file to review its changes line by line. Ensure that:
- The code addresses the requested problem.
- The implementation adheres to repository conventions.
- Error states and edge cases are properly handled.
- Tests cover the modified behavior.
- No unrelated files or behaviors were altered.
The preserved conversation can clarify Copilot’s reasoning. If needed, continue prompting Copilot in the sidebar for further explanations or modifications.
4. Make a Hands-On Edit
Once you understand the proposed changes, edit any file directly in VS Code for adjustments that are quicker or easier to make manually, such as:
- Refining a label or error message.
- Renaming a variable for clarity.
- Adjusting layout or styling.
- Adding a missing test case.
- Applying a repository-specific convention.
5. Run and Verify the Project Locally
Utilize the VS Code integrated terminal to execute the project’s validation workflow. Common commands may include:
npm installnpm testnpm run lintnpm run dev
Run the relevant tests, inspect failures, and verify the behavior as you would with code written by a person. If a localhost URL appears, open it to test the changes in a browser.
6. Continue with Copilot or Keep Editing Yourself
At any point, choose the interaction that best suits your needs:
- Prompt Copilot for repository-wide analysis or repetitive edits.
- Edit directly when you know the exact change required.
- Use both methods iteratively as you refine the implementation.
For example, after making a manual adjustment, you might ask Copilot to add a test for the updated label.
7. Commit and Push the Finished Changes
Once the implementation is ready, review the final diff and then commit and push the changes using the Source Control view or the integrated terminal:
git statusgit addgit commit -m "Refine session changes"git push
Follow your repository’s normal practices for branches, commits, reviews, and approvals. Since VS Code opened the worktree and branch associated with the session, pushing updates the pull request tracking that work.
A Continuous Workflow from Agent to Editor
Opening a Copilot app session in VS Code allows for a seamless workflow, enabling users to leverage Copilot for larger tasks while maintaining control for detailed reviews and testing. The session, diff, and worktree remain connected, facilitating a smooth transition between the Copilot app and VS Code.
Source: GitHub Blog