{"meta":{"title":"Remote sessions","intro":"Remote sessions sync to GitHub so users can access locally running Copilot sessions from the agents panel or on mobile. When enabled, the SDK produces a URL to the session log that can be shared as a link or QR code.","product":"GitHub Copilot","breadcrumbs":[{"href":"/en/enterprise-cloud@latest/copilot","title":"GitHub Copilot"},{"href":"/en/enterprise-cloud@latest/copilot/how-tos","title":"How-tos"},{"href":"/en/enterprise-cloud@latest/copilot/how-tos/copilot-sdk","title":"Copilot SDK"},{"href":"/en/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/features","title":"Features"},{"href":"/en/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/features/remote-sessions","title":"Remote Sessions"}],"documentType":"article"},"body":"# Remote sessions\n\nRemote sessions sync to GitHub so users can access locally running Copilot sessions from the agents panel or on mobile. When enabled, the SDK produces a URL to the session log that can be shared as a link or QR code.\n\n<!-- markdownlint-disable GHD046 GHD005 -->\n\n<!-- Suppressed: GHD046 (outdated release terminology), GHD005 (hardcoded data variable) -->\n\nFor running sessions on GitHub-hosted compute, see [Cloud sessions](/en/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/features/cloud-sessions).\n\n## Prerequisites\n\n* The user must be authenticated (GitHub token or logged-in user)\n* The session's working directory must be a GitHub repository\n\n## Enabling remote sessions\n\n### Always-on (client-level)\n\nSet `enableRemoteSessions: true` when creating the client. Every session in a GitHub repo automatically gets a remote URL.\n\n<!-- tabs:start -->\n\n#### TypeScript\n\n<!-- docs-validate: skip -->\n\n```typescript\nimport { CopilotClient } from \"@github/copilot-sdk\";\n\nconst client = new CopilotClient({ enableRemoteSessions: true });\nconst session = await client.createSession({\n  workingDirectory: \"/path/to/github-repo\",\n  onPermissionRequest: async () => ({ allowed: true }),\n});\n\nsession.on(\"session.info\", (event) => {\n  if (event.data.infoType === \"remote\") {\n    console.log(\"Remote URL:\", event.data.url);\n  }\n});\n```\n\n#### Python\n\n<!-- docs-validate: skip -->\n\n```python\nfrom copilot import CopilotClient\n\nclient = CopilotClient(enable_remote_sessions=True)\nsession = await client.create_session(\n    working_directory=\"/path/to/github-repo\",\n    on_permission_request=lambda req: {\"allowed\": True},\n)\n\ndef on_event(event):\n    if event.type == \"session.info\" and event.data.info_type == \"remote\":\n        print(f\"Remote URL: {event.data.url}\")\n\nsession.on(on_event)\n```\n\n#### Go\n\n<!-- docs-validate: skip -->\n\n```golang\nclient := copilot.NewClient(&copilot.ClientOptions{EnableRemoteSessions: true})\nsession, _ := client.CreateSession(ctx, &copilot.SessionConfig{\n    WorkingDirectory: \"/path/to/github-repo\",\n    OnPermissionRequest: func(req copilot.PermissionRequest, inv copilot.PermissionInvocation) (rpc.PermissionDecision, error) {\n        return &rpc.PermissionDecisionApproveOnce{}, nil\n    },\n})\n\nsession.On(func(event copilot.SessionEvent) {\n    if event.Type == \"session.info\" {\n        // Check infoType and extract URL\n    }\n})\n```\n\n#### C\\#\n\n<!-- docs-validate: skip -->\n\n```csharp\nvar client = new CopilotClient(new CopilotClientOptions { EnableRemoteSessions = true });\nvar session = await client.CreateSessionAsync(new SessionConfig\n{\n    WorkingDirectory = \"/path/to/github-repo\",\n    OnPermissionRequest = (req, inv) =>\n        Task.FromResult(PermissionDecision.ApproveOnce()),\n});\n\nsession.On((SessionEvent e) =>\n{\n    if (e is SessionInfoEvent info && info.Data.InfoType == \"remote\")\n    {\n        Console.WriteLine($\"Remote URL: {info.Data.Url}\");\n    }\n});\n```\n\n#### Rust\n\n<!-- docs-validate: skip -->\n\n```rust\nuse github_copilot_sdk::{Client, ClientOptions, SessionConfig};\nuse github_copilot_sdk::handler::PermissionResult;\n\nlet client = Client::start(\n    ClientOptions::new().with_enable_remote_sessions(true)\n).await?;\nlet session = client.create_session(\n    SessionConfig::new(\"/path/to/github-repo\")\n        .with_permission_handler(|_req, _inv| async {\n            Ok(PermissionResult::approve_once())\n        }),\n).await?;\n\nlet mut events = session.subscribe();\nwhile let Ok(event) = events.recv().await {\n    if event.event_type == \"session.info\" {\n        // Check info_type and extract URL\n    }\n}\n```\n\n<!-- tabs:end -->\n\n### On-demand (per-session toggle)\n\nUse `session.rpc.remote.enable()` to start remote access mid-session, and `session.rpc.remote.disable()` to stop it. This is equivalent to the CLI's `/remote on` and `/remote off` commands.\n\n<!-- tabs:start -->\n\n#### TypeScript\n\n<!-- docs-validate: skip -->\n\n```typescript\nconst result = await session.rpc.remote.enable();\nconsole.log(\"Remote URL:\", result.url);\n\n// Later: stop sharing\nawait session.rpc.remote.disable();\n```\n\n#### Python\n\n<!-- docs-validate: skip -->\n\n```python\nresult = await session.rpc.remote.enable()\nprint(f\"Remote URL: {result.url}\")\n\n# Later: stop sharing\nawait session.rpc.remote.disable()\n```\n\n#### Go\n\n<!-- docs-validate: skip -->\n\n```golang\nresult, err := session.RPC.Remote.Enable(ctx)\nif result.URL != nil {\n    fmt.Println(\"Remote URL:\", *result.URL)\n}\n\n// Later: stop sharing\nerr = session.RPC.Remote.Disable(ctx)\n```\n\n#### C\\#\n\n<!-- docs-validate: skip -->\n\n```csharp\nvar result = await session.Rpc.Remote.EnableAsync();\nConsole.WriteLine($\"Remote URL: {result.Url}\");\n\n// Later: stop sharing\nawait session.Rpc.Remote.DisableAsync();\n```\n\n#### Rust\n\n<!-- docs-validate: skip -->\n\n```rust\nlet result = session.rpc().remote().enable().await?;\nif let Some(url) = &result.url {\n    println!(\"Remote URL: {url}\");\n}\n\n// Later: stop sharing\nsession.rpc().remote().disable().await?;\n```\n\n<!-- tabs:end -->\n\n## QR code generation\n\nThe remote URL can be rendered as a QR code for easy mobile access. The SDK provides the URL—use your preferred QR code library:\n\n* **TypeScript**: [qrcode](https://www.npmjs.com/package/qrcode)\n* **Python**: [qrcode](https://pypi.org/project/qrcode/)\n* **Go**: [go-qrcode](https://github.com/skip2/go-qrcode)\n* **C#**: [QRCoder](https://www.nuget.org/packages/QRCoder)\n* **Rust**: [qrcode](https://crates.io/crates/qrcode)\n\n## Notes\n\n* The `enableRemoteSessions` client option applies when the SDK starts the runtime, either as a child process or as an in-process host. It is ignored when connecting to an already-running runtime.\n* If the working directory is not a GitHub repository, remote setup is silently skipped (always-on mode) or returns an error (on-demand mode).\n* Remote sessions require authentication. Ensure `gitHubToken` or `useLoggedInUser` is configured."}