如何在 VS Code 中继续 GitHub Copilot 应用会话
How to continue a GitHub Copilot app session in VS Code
GitHub 官方教程说明如何把 GitHub Copilot 应用中的会话直接在 VS Code 中打开并继续,会话的任务、计划和对话上下文、代码 diff 以及对应 worktree 都会一并保留。在 VS Code 中可逐行审查改动、手动编辑、用集成终端运行测试,最后提交并推送到该会话已关联的 pull request。
The agent has finished the bulk of your change. Now you want to inspect one implementation detail, adjust a few lines by hand, and run the project locally before you ship it.
But the work is sitting in the GitHub Copilot app… and your editor is where you review diffs, debug code, and make final adjustments. Do you have to choose between staying in the session and starting over in Visual Studio Code?
You don’t. You can open the Copilot app session directly in VS Code and continue with its conversation, code changes, and working context intact. That means Copilot can handle the repetitive or time-consuming work, then hand control back to you for closer review, hands-on editing, and local testing.
In this tutorial, you’ll learn how to:
- Open a Copilot app session in VS Code.
- Review the agent’s changes line by line.
- Continue the same conversation from your editor.
- Modify and test the code locally.
- Push your updates to the pull request associated with the session.
Prerequisites
Before you begin, make sure you have:
- The GitHub Copilot app installed and signed in.
- Visual Studio Code installed and connected to the same GitHub account.
- A Copilot app session with code changes you want to review or continue.
- Permission to work in and push changes to the session’s repository.
This tutorial assumes you are already comfortable navigating VS Code, running commands in its integrated terminal, and working with Git branches and pull requests.
1. Start with a session in the Copilot app
Open the session you want to continue. Before handing it off, take a moment to review the task and the work Copilot completed.
A session contains more than a collection of modified files. It also records the task, the plan, and the conversation that produced those changes. That context is important when you want to understand why Copilot chose a particular implementation or ask it to revise part of the work.
You do not need to summarize that history or copy it into a new chat before moving to VS Code.
2. Open the session in VS Code
From the session, select Open in VS Code. If the app presents more than one supported editor or VS Code installation, choose the one you want to use.
VS Code opens the project using the worktree associated with the session. It also displays the existing session in the Copilot sidebar.
That gives you three connected pieces of the original work:
- The session context: The task, plan, and conversation remain available.
- The diff: The files and lines changed by the agent are ready for review.
- The worktree: VS Code opens the same isolated working tree the session used.
You are continuing the existing session, not reconstructing it in a new editor window.
3. Review the agent’s changes
Before editing, inspect the diff in VS Code. Open the Source Control view to see the changed files, then select a file to review its changes line by line.
Review the implementation as you would any other proposed change. In particular, check that:
- The code solves the requested problem.
- The implementation follows the repository’s conventions.
- Error states and edge cases are handled appropriately.
- Tests cover the behavior that changed.
- No unrelated files or behaviors were modified.
The preserved conversation can help explain how Copilot arrived at the implementation. If something is unclear, continue prompting Copilot in the sidebar. For example:
Explain why you changed this function instead of adding a new helper. Identify any behavior this could affect.You can also ask Copilot to make another change. Because the session and worktree remain connected, you do not have to describe the task from the beginning.
4. Make a hands-on edit
Once you understand the proposed changes, edit any file directly in VS Code.
This is useful for adjustments that are faster or easier to make by hand, 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.
You are editing the session’s existing worktree, so your manual changes build directly on the agent’s work. You do not need to copy files between directories or manually re-create the branch.
5. Run and verify the project locally
Use the VS Code integrated terminal to run the project’s normal validation workflow. The exact commands depend on the repository, but some web app examples may include:
npm installnpm testnpm run lintnpm run dev
Treat agent-generated changes the same way you would treat code written by a person: run the relevant tests, inspect failures, and verify the behavior yourself.
If the development server prints a localhost URL, open it to test the change in a browser. When supported by your VS Code setup, you can open the URL in VS Code’s integrated browser and inspect the result without leaving the editor.
For a user-interface change, verify both the requested behavior and nearby states. For example, check the modified component at different viewport sizes and confirm that loading, empty, and error states still work.
6. Continue with Copilot or keep editing yourself
At any point, you can choose the interaction that best fits the next step:
- Prompt Copilot when the change requires repository-wide analysis or repetitive edits.
- Edit directly when you know the exact change you want.
- Use both approaches iteratively as you test and refine the implementation.
For example, after making a manual UI adjustment, you might ask Copilot:
Add a test for the updated label and run the relevant test file. Do not modify unrelated components.
Because you are still in the original session, Copilot retains the context needed to interpret “the updated label.”
7. Commit and push the finished changes
When the implementation is ready, review the final diff one more time. 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
Use your repository’s normal branch, commit, review, and approval practices. Because VS Code opened the worktree and branch associated with the session, pushing the branch updates the pull request already tracking that work.
There is no need to copy the finished files into another checkout or reconnect the work to the pull request manually.
A continuous workflow from agent to editor
Opening a Copilot app session in VS Code gives you a clean division of labor without splitting the work itself. Copilot can take on a larger or repetitive implementation, while you can move into the editor for detailed review, targeted changes, local testing, and final polish.
The session, diff, and worktree move with you. Start by directing the work in the Copilot app, switch to VS Code whenever you want hands-on control, and push the finished result through the same pull request workflow.
Ready to try it? Download the GitHub Copilot app, start a session, and open it in VS Code when you are ready to continue coding.
The post How to continue a GitHub Copilot app session in VS Code appeared first on The GitHub Blog.
来源:GitHub Blog · AI & ML · github.blog