Skip to content

Upstream sync: Port Commands, Elicitation, Session Capabilities, and getSessionMetadata (27 commits)#52

Merged
brunoborges merged 7 commits intomainfrom
copilot/sync-upstream-27-commits
Apr 6, 2026
Merged

Upstream sync: Port Commands, Elicitation, Session Capabilities, and getSessionMetadata (27 commits)#52
brunoborges merged 7 commits intomainfrom
copilot/sync-upstream-27-commits

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

Ports 27 upstream commits from github/copilot-sdk (up to f7fd757). Updates .lastmerge accordingly.

Before the change?

  • No support for slash commands in sessions
  • No elicitation (UI dialog) API
  • No session capability reporting
  • No per-session metadata lookup by ID
  • Permission events resolved by a pre-hook were still dispatched to the client-side handler
  • SessionUiApi Javadoc used ?. (not valid Java syntax) in the prose description
  • README listed "GitHub Copilot 1.0.17" instead of "GitHub Copilot CLI 1.0.17"

After the change?

Slash Commands — Register /command handlers invoked from the CLI TUI:

new SessionConfig()
    .setCommands(List.of(
        new CommandDefinition()
            .setName("deploy")
            .setDescription("Deploy the current branch")
            .setHandler(ctx -> { /* ... */ return CompletableFuture.completedFuture(null); })
    ))
  • command.execute events dispatched to registered handlers; responds via session.commands.handlePendingCommand
  • commandName null-checked before ConcurrentHashMap lookup to prevent NullPointerException
  • Wire: commands sent as CommandWireDefinition list in create/resume requests

Elicitation (UI Dialogs) — Two directions:

  • Incoming: onElicitationRequest handler receives elicitation requests from server/MCP tools; requestElicitation=true advertises support
  • Outgoing: session.getUi().confirm() / .select() / .input() / .elicitation() for proactive dialogs when host supports it

Session Capabilitiessession.getCapabilities() populated from create/resume response and updated via capabilities.changed events:

var caps = session.getCapabilities();
if (caps.getUi() != null && Boolean.TRUE.equals(caps.getUi().getElicitation())) {
    boolean ok = session.getUi().confirm("Proceed?").get();
}

getSessionMetadata(sessionId) — O(1) session lookup by ID on CopilotClient (vs. scanning all sessions with listSessions()).

resolvedByHook fix — Permission events already resolved by a pre-hook now short-circuit before invoking the client-side permission handler.

Javadoc / docs fixesSessionUiApi prose now uses valid Java null-check syntax instead of ?.; README updated to say "GitHub Copilot CLI 1.0.17".

New Types

  • json/: CommandDefinition, CommandContext, CommandHandler, CommandWireDefinition, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationParams, ElicitationResultAction, ElicitationHandler, InputOptions, SessionCapabilities, SessionUiCapabilities, SessionUiApi, GetSessionMetadataResponse
  • events/: CommandExecuteEvent, ElicitationRequestedEvent, CapabilitiesChangedEvent

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • mvn spotless:apply has been run to format the code
  • mvn clean verify passes locally

Does this introduce a breaking change?

  • Yes
  • No

Copilot AI linked an issue Apr 6, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Sync upstream with 27 new commits Upstream sync: Port Commands, Elicitation, Session Capabilities, and getSessionMetadata (27 commits) Apr 6, 2026
Copilot AI requested a review from edburns April 6, 2026 11:02
@brunoborges brunoborges marked this pull request as ready for review April 6, 2026 17:06
Copilot AI review requested due to automatic review settings April 6, 2026 17:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports upstream changes to add slash commands, elicitation (UI dialogs), session capability reporting/updates, and efficient per-session metadata lookup.

Changes:

  • Add command registration and command.execute event handling, including wire-format support in create/resume requests.
  • Add elicitation support (incoming handler + outgoing session.getUi() API) and session capabilities populated from create/resume + capabilities.changed.
  • Add CopilotClient.getSessionMetadata(sessionId) plus tests and documentation updates (including required CLI version bump).
Show a summary per file
File Description
src/test/java/com/github/copilot/sdk/ElicitationTest.java Adds unit tests for elicitation DTOs, cloning behavior, and request flags.
src/test/java/com/github/copilot/sdk/CopilotSessionTest.java Adds snapshot test for getSessionMetadata(sessionId) behavior.
src/test/java/com/github/copilot/sdk/CommandsTest.java Adds unit tests for command DTOs, cloning behavior, and wire serialization.
src/site/markdown/index.md Updates documented minimum Copilot CLI version.
src/site/markdown/advanced.md Documents slash commands, elicitation, capabilities, and session-metadata-by-id.
src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java Includes commands + requestElicitation in create/resume requests; registers handlers on session.
src/main/java/com/github/copilot/sdk/json/SessionUiCapabilities.java Introduces UI capability flag model (elicitation).
src/main/java/com/github/copilot/sdk/json/SessionUiApi.java Introduces UI API surface for elicitation convenience methods.
src/main/java/com/github/copilot/sdk/json/SessionConfig.java Adds commands + elicitation handler to session config (+ clone support).
src/main/java/com/github/copilot/sdk/json/SessionCapabilities.java Adds capabilities container DTO.
src/main/java/com/github/copilot/sdk/json/ResumeSessionResponse.java Extends resume response to include capabilities.
src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java Extends resume request to include commands + requestElicitation.
src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java Adds commands + elicitation handler to resume config (+ clone support).
src/main/java/com/github/copilot/sdk/json/InputOptions.java Adds options DTO for ui.input(...).
src/main/java/com/github/copilot/sdk/json/GetSessionMetadataResponse.java Adds RPC response wrapper for metadata-by-id call.
src/main/java/com/github/copilot/sdk/json/ElicitationSchema.java Adds JSON-schema DTO used for elicitation dialogs.
src/main/java/com/github/copilot/sdk/json/ElicitationResultAction.java Adds action enum for elicitation results.
src/main/java/com/github/copilot/sdk/json/ElicitationResult.java Adds elicitation result DTO.
src/main/java/com/github/copilot/sdk/json/ElicitationParams.java Adds outgoing elicitation request params DTO.
src/main/java/com/github/copilot/sdk/json/ElicitationHandler.java Adds functional interface for incoming elicitation handling.
src/main/java/com/github/copilot/sdk/json/ElicitationContext.java Adds context DTO for incoming elicitation requests.
src/main/java/com/github/copilot/sdk/json/CreateSessionResponse.java Extends create response to include capabilities.
src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java Extends create request to include commands + requestElicitation.
src/main/java/com/github/copilot/sdk/json/CommandWireDefinition.java Adds wire DTO for command definitions sent over RPC.
src/main/java/com/github/copilot/sdk/json/CommandHandler.java Adds functional interface for slash command handling.
src/main/java/com/github/copilot/sdk/json/CommandDefinition.java Adds command definition DTO (name/description/handler).
src/main/java/com/github/copilot/sdk/json/CommandContext.java Adds context DTO passed to command handlers.
src/main/java/com/github/copilot/sdk/events/SessionEventParser.java Registers new event types (command.execute, elicitation.requested, capabilities.changed).
src/main/java/com/github/copilot/sdk/events/PermissionRequestedEvent.java Adds resolvedByHook field to support short-circuit behavior.
src/main/java/com/github/copilot/sdk/events/ElicitationRequestedEvent.java Adds event type for incoming elicitation requests.
src/main/java/com/github/copilot/sdk/events/CommandExecuteEvent.java Adds event type for slash command execution requests.
src/main/java/com/github/copilot/sdk/events/CapabilitiesChangedEvent.java Adds event type for capability updates.
src/main/java/com/github/copilot/sdk/events/AbstractSessionEvent.java Updates sealed hierarchy to include new event classes.
src/main/java/com/github/copilot/sdk/CopilotSession.java Implements command execution + elicitation handling, UI API, and capabilities updates.
src/main/java/com/github/copilot/sdk/CopilotClient.java Populates session capabilities and adds getSessionMetadata(sessionId) RPC.
README.md Updates documented minimum Copilot version.
.lastmerge Advances upstream sync marker to f7fd757.

Copilot's findings

Comments suppressed due to low confidence (3)

src/main/java/com/github/copilot/sdk/CopilotSession.java:979

  • handleElicitationRequestAsync assumes the elicitation handler completes with a non-null ElicitationResult. If a user handler returns CompletableFuture.completedFuture(null), result.getAction()/getContent() will throw a NullPointerException and no response will be sent. Treat a null result as CANCEL (and send a cancel response) to make the API more robust.
                handler.handle(context).thenAccept(result -> {
                    try {
                        String actionStr = result.getAction() != null
                                ? result.getAction().getValue()
                                : ElicitationResultAction.CANCEL.getValue();
                        Map<String, Object> resultMap = result.getContent() != null
                                ? Map.of("action", actionStr, "content", result.getContent())
                                : Map.of("action", actionStr);

src/main/java/com/github/copilot/sdk/CopilotSession.java:1043

  • SessionUiApiImpl.elicitation dereferences params and params.getRequestedSchema() without validation. Passing null params (or a params object with null requestedSchema) will currently fail with a NullPointerException. Consider validating inputs and throwing an IllegalArgumentException with a clear message (e.g., require non-null params, message, and requestedSchema).
        public CompletableFuture<ElicitationResult> elicitation(ElicitationParams params) {
            assertElicitation();
            var schema = new java.util.HashMap<String, Object>();
            schema.put("type", params.getRequestedSchema().getType());
            schema.put("properties", params.getRequestedSchema().getProperties());
            if (params.getRequestedSchema().getRequired() != null) {

src/main/java/com/github/copilot/sdk/CopilotSession.java:1029

  • The IllegalStateException message mentions getUi()?.getElicitation(), but ?. is not valid Java syntax. This can confuse SDK users trying to follow the guidance. Update the message to use a Java-accurate check (e.g., caps.getUi() != null && Boolean.TRUE.equals(caps.getUi().getElicitation())).
        SessionCapabilities caps = capabilities;
        if (caps == null || caps.getUi() == null || !Boolean.TRUE.equals(caps.getUi().getElicitation())) {
            throw new IllegalStateException("Elicitation is not supported by the host. "
                    + "Check session.getCapabilities().getUi()?.getElicitation() before calling UI methods.");
        }
  • Files reviewed: 37/37 changed files
  • Comments generated: 3

brunoborges and others added 2 commits April 6, 2026 13:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI requested a review from brunoborges April 6, 2026 17:43
@brunoborges brunoborges merged commit 9724b8e into main Apr 6, 2026
8 checks passed
@edburns edburns mentioned this pull request Apr 6, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upstream sync: 27 new commits (2026-04-06)

4 participants