Introduce TUI server mode so ask_user can be intercepted without replacing entire TUI
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu trong dotnet/src/Types.cs và Client.cs, đặc biệt là StartCliServerAsync, vòng lặp phát hiện port và vòng lặp thu thập stderr. Xác nhận flag CLI, định tuyến TCP cho userInput.request và hành vi của port với nhóm CLI trước khi thay đổi SDK. Được xem là hoàn tất khi TuiServerMode đã được xác thực, khởi chạy đúng mode dự kiến, giữ nguyên đầu ra của terminal và có các bài test cho việc xử lý tùy chọn của nó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
According to copilot analysis, there's a --ui-server switch in the sources of the SDK that could be used to preserve the full copilot TUI while intercepting events via TCP.
Unknowns to raise with the CLI team
-
CLI flag name — SDK source comments say --ui-server; copilot --help shows --acp. Which flag actually starts "TUI+server" mode? Are they the same thing?
-
ask_user routing — This is the key question. When the CLI is in TUI+server mode AND an SDK client is connected via TCP, does the CLI:
a. Route
userInput.requestto the SDK client (over TCP), letting the SDK handler intercept it? ← what you need
b. Handleask_userin the TUI itself and not send userInput.request to the SDK at all?If it's currently (b), a small CLI-side change would be needed: when an SDK client is connected and has registered a userInput.request handler, prefer routing to the client.
-
Port announcement — When running without --headless, does the CLI still write "Listening on port N" to stdout (now the terminal)? That's fine to leave in — users won't mind seeing
it once on startup — but the SDK approach above bypasses it entirely by requiring an explicit port.
Proposal: Add TuiServerMode to CopilotClientOptions. Launches the CLI with its full terminal UX intact (streaming, colors, tool indicators, etc.) while the SDK connects via TCP to intercept only specific callbacks — specifically OnUserInputRequest — replacing the CLI's own prompt with a custom UX (e.g. a native popup). All stdout/stderr flow through to the user's terminal unchanged.
The SDK diff is ~30 lines. The only thing that may require CLI cooperation is whether userInput.request is already routed to TCP clients in TUI+server mode.
SDK changes needed (dotnet/src/)
- Types.cs — new option on CopilotClientOptions
/// <summary>
/// When true, launches the CLI in TUI+server mode (--ui-server) instead of
/// headless mode. The CLI renders its own terminal UX while the SDK connects
/// via TCP to intercept callbacks such as <see cref="SessionConfig.OnUserInputRequest"/>.
/// Requires <see cref="Port"/> to be set (stdout is not available for port discovery).
/// Mutually exclusive with <see cref="UseStdio"/>.
/// </summary>
public bool TuiServerMode { get; set; }
- Client.cs — StartCliServerAsync, args
- args.AddRange(["--headless", "--no-auto-update", "--log-level", options.LogLevel]);
+ if (options.TuiServerMode)
+ args.Add("--ui-server"); // ← CLI flag name TBD (see unknowns)
+ else
+ args.Add("--headless");
+ args.AddRange(["--no-auto-update", "--log-level", options.LogLevel]);
- Client.cs — StartCliServerAsync, ProcessStartInfo
var startInfo = new ProcessStartInfo
{
...
- RedirectStandardInput = options.UseStdio,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- CreateNoWindow = true,
+ RedirectStandardInput = options.UseStdio && !options.TuiServerMode,
+ RedirectStandardOutput = !options.TuiServerMode,
+ RedirectStandardError = !options.TuiServerMode,
+ CreateNoWindow = !options.TuiServerMode,
};
- Client.cs — StartCliServerAsync, port discovery
- var detectedLocalhostTcpPort = (int?)null;
- if (!options.UseStdio)
- {
- // reads port announcement from stdout...
- }
+ var detectedLocalhostTcpPort = options.TuiServerMode
+ ? options.Port // must be pre-configured; stdout is the user's terminal
+ : await DetectPortFromStdoutAsync(options, cliProcess, cancellationToken);
(extract the existing port-reading loop into DetectPortFromStdoutAsync)
- Client.cs — validation in constructor
+ if (options.TuiServerMode && options.UseStdio)
+ throw new ArgumentException("TuiServerMode is mutually exclusive with UseStdio");
+ if (options.TuiServerMode && options.Port <= 0)
+ throw new ArgumentException("TuiServerMode requires Port to be set explicitly");
The stderr capture loop (lines ~1247–1265) is also skipped when TuiServerMode — otherwise it would try to read from an unredirected stream.
- Ngôn ngữ chính
- Java
- Star
- 10.5k
- Fork
- 1.5k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 126
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/copilot-sdk
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/copilot-sdk#2760 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/copilot-sdk#2759 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
github/copilot-sdk#2758 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
github/copilot-sdk#2709 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
github/copilot-sdk#2673 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của github/copilot-sdk
Issue tương tự
-
TerminalRow.mSpaceUsed (short) overflows on terminals wider than 1023 columns, crashing setCharĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
termux/termux-app#5340 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
apache/rocketmq-dashboard#5110 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 4 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
TS2502 in shipped .d.ts: `compileHighlightConfig` parameter shadows the de-aliased `Query` typeĐang mởbug javascript
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày