|
| 1 | +--- |
| 2 | +title: Steering a {% data variables.copilot.copilot_cli %} session from another device |
| 3 | +shortTitle: Steer a session remotely |
| 4 | +allowTitleToDifferFromFilename: true |
| 5 | +intro: 'Enable remote access to a {% data variables.copilot.copilot_cli_short %} session so you can monitor progress, respond to prompts, and continue working from {% data variables.product.prodname_dotcom_the_website %} or {% data variables.product.prodname_mobile %}.' |
| 6 | +versions: |
| 7 | + feature: copilot |
| 8 | +contentType: how-tos |
| 9 | +category: |
| 10 | + - Author and optimize with Copilot # Copilot discovery page |
| 11 | + - Build with Copilot CLI # Copilot CLI bespoke page |
| 12 | +docsTeamMetrics: |
| 13 | + - copilot-cli |
| 14 | +--- |
| 15 | + |
| 16 | +Remote access lets you connect to a running {% data variables.copilot.copilot_cli_short %} session from any browser or from {% data variables.product.prodname_mobile %}. You can view session output, respond to permission requests, and continue working in the session without being at the machine where the session is running. |
| 17 | + |
| 18 | +This article explains how to enable and use remote access. For more conceptual information, see [AUTOTITLE](/copilot/concepts/agents/copilot-cli/about-remote-access). |
| 19 | + |
| 20 | +{% data reusables.cli.public-preview-remote-access %} |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +* The machine where the CLI session is running must be online, with the session actively running in a terminal. |
| 25 | + |
| 26 | + > [!TIP] |
| 27 | + > Use the `/keep-alive` slash command to prevent your machine from going to sleep while you're away. See [Preventing your machine from going to sleep](#preventing-your-machine-from-going-to-sleep). |
| 28 | +
|
| 29 | +* The working directory must contain a Git repository hosted on {% data variables.product.prodname_dotcom_the_website %}. If you are not in a {% data variables.product.prodname_dotcom %} repository, the CLI displays: "Remote session disabled: not in a {% data variables.product.github %} repository." |
| 30 | + |
| 31 | +## Enabling remote access for a session |
| 32 | + |
| 33 | +You can enable remote access in three ways: |
| 34 | + |
| 35 | +* With a slash command during an interactive session. |
| 36 | +* With a command-line option when you start {% data variables.copilot.copilot_cli_short %}. |
| 37 | +* By configuring the CLI to enable remote access by default for all interactive sessions. |
| 38 | + |
| 39 | +### Using the `/remote` slash command |
| 40 | + |
| 41 | +If you are already in an interactive session and want to enable remote access, enter: |
| 42 | + |
| 43 | +```copilot copy |
| 44 | +/remote |
| 45 | +``` |
| 46 | + |
| 47 | +The CLI connects to {% data variables.product.prodname_dotcom_the_website %} and displays details for accessing the session remotely—see [Accessing a session from {% data variables.product.prodname_dotcom_the_website %}](#accessing-a-session-from-githubcom) and [Accessing a session from {% data variables.product.prodname_mobile %}](#accessing-a-session-from-github-mobile) later in this article. |
| 48 | + |
| 49 | +### Using the `--remote` command-line option |
| 50 | + |
| 51 | +If you think you may want to access a session remotely, you can start the CLI with the `--remote` command-line option. This avoids the need to remember to use the `/remote` slash command during the session. |
| 52 | + |
| 53 | +```bash copy |
| 54 | +copilot --remote |
| 55 | +``` |
| 56 | + |
| 57 | +Details for accessing the session remotely are displayed when the interactive session starts and can be displayed again at any time by using the `/remote` slash command. |
| 58 | + |
| 59 | +### Configuring remote access to always be enabled |
| 60 | + |
| 61 | +If you always want your interactive CLI sessions to be remotely accessible, add the following to your {% data variables.product.prodname_copilot_short %} configuration file (typically located at `~/.copilot/config.json`): |
| 62 | + |
| 63 | +```json copy |
| 64 | +{ |
| 65 | + "steerableSessions": true |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +To override this setting for a particular session, use the `--no-remote` option when you start the session: |
| 70 | + |
| 71 | +```bash copy |
| 72 | +copilot --no-remote |
| 73 | +``` |
| 74 | + |
| 75 | +> [!NOTE] |
| 76 | +> The command-line options `--remote` and `--no-remote` always take precedence over the `remoteSessions` setting in the configuration file. |
| 77 | +
|
| 78 | +## Accessing a session from {% data variables.product.prodname_dotcom_the_website %} |
| 79 | + |
| 80 | +When remote access is enabled, the CLI displays a link in the format: |
| 81 | + |
| 82 | +```text |
| 83 | +https://github.com/OWNER/REPO/tasks/TASK_ID |
| 84 | +``` |
| 85 | + |
| 86 | +Use this link to access the session in a web browser. You must be signed in to {% data variables.product.prodname_dotcom %} with the same account that started the CLI session. |
| 87 | + |
| 88 | +You can also access the session from your list of recent agent sessions on {% data variables.product.prodname_dotcom_the_website %}: |
| 89 | + |
| 90 | +1. In the top-left corner of {% data variables.product.prodname_dotcom %}, click {% octicon "three-bars" aria-label="Open menu" %}. |
| 91 | +1. Click **{% octicon "copilot" aria-hidden="true" aria-label="copilot" %} {% data variables.product.prodname_copilot_short %}**. |
| 92 | +1. Under "Recent agent sessions", click your {% data variables.copilot.copilot_cli_short %} session to open it. |
| 93 | + |
| 94 | +> [!IMPORTANT] |
| 95 | +> Sessions are user-specific: you can only access your own {% data variables.copilot.copilot_cli_short %} sessions. Other {% data variables.product.github %} users cannot access your sessions. |
| 96 | +
|
| 97 | +## Accessing a session from {% data variables.product.prodname_mobile %} |
| 98 | + |
| 99 | +A {% data variables.copilot.copilot_cli_short %} session is available in {% data variables.product.prodname_mobile %} as soon as you enable remote access. To find your session in {% data variables.product.prodname_mobile %}: |
| 100 | + |
| 101 | +1. Tap the **{% octicon "copilot" aria-hidden="true" aria-label="copilot" %} {% data variables.product.prodname_copilot_short %}** button in the bottom right corner of the screen. |
| 102 | + |
| 103 | + The session is listed under "Agent sessions." |
| 104 | + |
| 105 | +1. Tap the session to open it. |
| 106 | + |
| 107 | +### Use a QR code to quickly open a session on your phone |
| 108 | + |
| 109 | +1. In an interactive session, enter the `/remote` slash command to redisplay the remote session details. |
| 110 | +1. Press <kbd>Ctrl</kbd>+<kbd>E</kbd> to toggle on/off display of a QR code. |
| 111 | + |
| 112 | + > [!NOTE] |
| 113 | + > This keyboard shortcut expands/collapses all details in the session conversation, not just the QR code. It only works if the input field is currently empty. |
| 114 | +
|
| 115 | +1. Scan the QR code with your phone to go directly to the session in {% data variables.product.prodname_mobile %}. |
| 116 | + |
| 117 | +## Preventing your machine from going to sleep |
| 118 | + |
| 119 | +You can use the `/keep-alive` slash command to prevent your machine from going to sleep. This allows you to maintain the remote connection and continue interacting with the session from {% data variables.product.prodname_dotcom_the_website %} or {% data variables.product.prodname_mobile %}. |
| 120 | + |
| 121 | +In an interactive session, enter `/keep-alive OPTION`, where `OPTION` is one of: |
| 122 | + |
| 123 | +* `on`: Prevents the machine from going to sleep while the CLI session is active. |
| 124 | +* `off`: Allows the machine to go to sleep as normal. |
| 125 | +* `busy`: Prevents the machine from going to sleep only while {% data variables.product.prodname_copilot_short %} is working on a task. Once the agent completes a task the machine can go to sleep as normal. The machine will not go to sleep if {% data variables.product.prodname_copilot_short %} is waiting for you to respond to a request for input from you. |
| 126 | +* `NUMBERm`, `NUMBERh`, or `NUMBERd` (for example, `30m`, `8h`, `1d`): Prevents the machine from going to sleep for a specific number of minutes, hours, or days. If a bare number is provided without a suffix, it is treated as minutes. |
| 127 | + |
| 128 | +Without passing an `OPTION`, the `/keep-alive` command displays the current keep-alive status. |
| 129 | + |
| 130 | +## Resuming a session with remote access |
| 131 | + |
| 132 | +When you shut down a session that has remote access enabled, the CLI displays a resume command that includes `--remote`: |
| 133 | + |
| 134 | +```bash |
| 135 | +copilot --resume=SESSION_ID --remote |
| 136 | +``` |
| 137 | + |
| 138 | +Use this command to restart the session with remote access enabled. |
| 139 | + |
| 140 | +Similarly, adding `--remote` to a `copilot --continue` command resumes the most recent session with remote access enabled. |
| 141 | + |
| 142 | +If you have `"remoteSessions": true` in your {% data variables.product.prodname_copilot_short %} configuration file, resumed sessions will have remote access enabled automatically and you do not need to use the `--remote` option. |
| 143 | + |
| 144 | +## Preventing remote access |
| 145 | + |
| 146 | +Remote access is disabled by default, but may be enabled in your {% data variables.product.prodname_copilot_short %} configuration file. You can ensure a session is not remotely accessible by: |
| 147 | + |
| 148 | +* **For a single session**: Start the CLI with `--no-remote` to prevent remote access for that session, regardless of your configuration file setting. |
| 149 | +* **Permanently**: Remove the `"remoteSessions": true` setting from your {% data variables.product.prodname_copilot_short %} configuration file (or set it to `false`). |
0 commit comments