-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathremote_session.cpp
More file actions
72 lines (59 loc) · 2.04 KB
/
Copy pathremote_session.cpp
File metadata and controls
72 lines (59 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) 2025 Elias Bachaalany
// SPDX-License-Identifier: MIT
/// @file remote_session.cpp
/// @brief Compile-only demo for the v0.1.49 `remoteSession` field on
/// `SessionConfig` (Mission Control integration, upstream nodejs PR #1295).
///
/// Demonstrates the three `RemoteSessionMode` values and shows how the
/// resulting `session.create` payload differs. No live Copilot CLI is
/// required: the example uses the public `build_session_create_request`
/// helper to render each request payload for inspection.
///
/// Remote-session modes (matches upstream nodejs):
/// * `Off` — explicitly disable remote steering for this session.
/// * `Export` — export this session so it shows up in Mission Control
/// without accepting remote commands.
/// * `On` — enable full remote steering from GitHub web / mobile.
#include <copilot/copilot.hpp>
#include <iostream>
#include <string>
#include <vector>
namespace
{
const char* mode_name(copilot::RemoteSessionMode mode)
{
using copilot::RemoteSessionMode;
switch (mode)
{
case RemoteSessionMode::Off: return "off";
case RemoteSessionMode::Export: return "export";
case RemoteSessionMode::On: return "on";
}
return "?";
}
} // namespace
int main()
{
using namespace copilot;
const std::vector<RemoteSessionMode> modes = {
RemoteSessionMode::Off,
RemoteSessionMode::Export,
RemoteSessionMode::On,
};
for (auto mode : modes)
{
SessionConfig cfg;
cfg.client_name = "remote-session-demo";
cfg.remote_session = mode;
cfg.enable_session_telemetry = (mode != RemoteSessionMode::Off);
json request = build_session_create_request(cfg);
std::cout << "[mode=" << mode_name(mode) << "] session.create payload:\n";
std::cout << request.dump(2) << "\n\n";
if (!request.contains("remoteSession"))
{
std::cerr << "remoteSession field missing for mode " << mode_name(mode) << "\n";
return 1;
}
}
return 0;
}