Skip to content

Upstream sync: Add clone() methods to config classes (6 commits)#138

Merged
brunoborges merged 12 commits intomainfrom
copilot/sync-upstream-commits
Feb 17, 2026
Merged

Upstream sync: Add clone() methods to config classes (6 commits)#138
brunoborges merged 12 commits intomainfrom
copilot/sync-upstream-commits

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Upstream Sync: 6 commits from github/copilot-sdk (304d812...5016587)

Summary

Successfully ported relevant changes from 6 upstream commits. The main change was adding clone() methods to configuration classes, following Java idioms for shallow cloning.

Commits Analyzed

  • 5016587 - Fix Available SDKs table Location links to point to SDK subfolders (#486)
  • 46a1239 - Change Node engine requirement to 20+. Use 22 for CI.
  • f1038d7 - Hide CLI console window on Windows across all SDKs (#329)
  • 273c425 - Allow custom npm registry URL for downloading Copilot from dotnet SDK (#463)
  • f460b5d - Fix maccatalyst RID detection in SDK targets (#485)
  • ce54e43 - Add copy constructors and Clone methods to the various .NET config option bags (#422)

Changes Ported

Clone methods (ce54e43) - Added clone() methods to config classes:

  • CopilotClientOptions - shallow clone with array and map independence
  • SessionConfig - shallow clone with list/map independence
  • ResumeSessionConfig - shallow clone with list/map independence
  • MessageOptions - shallow clone with list independence

Windows console hiding (f1038d7) - Added clarifying comment in CliServerManager explaining Java's behavior

Tests - Added ConfigCloneTest with 8 comprehensive test cases covering:

  • Basic property copying
  • Array/collection independence
  • Environment map independence
  • Null value preservation

Changes NOT Ported (Intentional)

README.md table fix (5016587) - Not applicable, Java SDK is in separate repository

Node.js engine requirement (46a1239) - Node.js CI-specific, not applicable to Java SDK

Custom npm registry URL (273c425) - .NET build-time feature for bundled CLI download. Java SDK expects users to install CLI separately via PATH

maccatalyst RID detection (f460b5d) - .NET build-time feature for platform detection. Java SDK doesn't bundle CLI executables

Verification

  • ✅ All 391 tests pass (including 8 ConfigCloneTest cases)
  • ✅ Build successful: mvn clean verify
  • ✅ Code formatted with Spotless
  • ✅ Updated .lastmerge to 5016587a62652f3d184b3c6958dfc63359921aa8
Original prompt

This section details on the original issue you should resolve

<issue_title>[upstream-sync] 6 new commits (2026-02-17)</issue_title>
<issue_description>The official Copilot SDK has 6 new commits since the last merge.

Commit Range

304d812...5016587

Recent Commits

  • 5016587 Fix Available SDKs table Location links to point to SDK subfolders (#486)
  • 46a1239 Change Node engine requirement to 20+. Use 22 for CI.
  • f1038d7 Hide CLI console window on Windows across all SDKs (#329)
  • 273c425 Allow custom npm registry URL for downloading Copilot from dotnet SDK (#463)
  • f460b5d Fix maccatalyst RID detection in SDK targets (#485)
  • ce54e43 Add copy constructors and Clone methods to the various .NET config option bags (#422)

Instructions: Follow the agentic-merge-upstream prompt to port these changes to the Java SDK.

AI generated by Weekly Upstream Sync Agentic Workflow

  • expires on Feb 23, 2026, 9:32 AM UTC

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 17, 2026 09:41
Port upstream commit ce54e43: Add copy constructors and Clone methods to the various .NET config option bags (#422)

Added clone() methods to:
- CopilotClientOptions
- SessionConfig
- ResumeSessionConfig
- MessageOptions

These methods create shallow clones where mutable collection properties (lists, maps, arrays) are copied into new instances to ensure independence, while other reference-type properties are shared.

Also added comprehensive tests in ConfigCloneTest to verify the clone behavior.

Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Copilot AI changed the title [WIP] Sync latest upstream commits from Copilot SDK Upstream sync: Add clone() methods to config classes (6 commits) Feb 17, 2026
Copilot AI requested a review from brunoborges February 17, 2026 09:45
@brunoborges brunoborges marked this pull request as ready for review February 17, 2026 12:31
@brunoborges brunoborges requested a review from Copilot February 17, 2026 12:31
Copy link
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 shallow clone() helpers for SDK configuration “option bag” classes, improving ergonomics when deriving modified configs without mutating the original, and syncs upstream merge tracking.

Changes:

  • Added shallow clone() methods to CopilotClientOptions, SessionConfig, ResumeSessionConfig, and MessageOptions.
  • Added ConfigCloneTest to validate cloning semantics.
  • Clarified Windows console window behavior comment in CliServerManager and updated .lastmerge to the new upstream commit.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java Adds clone() for client options (arrays copied; other fields currently shared).
src/main/java/com/github/copilot/sdk/json/SessionConfig.java Adds clone() for new-session configuration, copying list/map fields.
src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java Adds clone() for resume-session configuration, copying list/map fields.
src/main/java/com/github/copilot/sdk/json/MessageOptions.java Adds clone() for message options, copying attachments list.
src/test/java/com/github/copilot/sdk/ConfigCloneTest.java Introduces unit tests for clone behavior.
src/main/java/com/github/copilot/sdk/CliServerManager.java Adds explanatory comment about Windows console window behavior in Java.
.lastmerge Updates tracked upstream commit hash to 5016587....

Comment on lines 24 to 30
original.setCliPath("/usr/local/bin/copilot");
original.setLogLevel("debug");
original.setPort(9000);

CopilotClientOptions cloned = original.clone();

assertEquals(original.getCliPath(), cloned.getCliPath());
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

ConfigCloneTest currently includes trailing whitespace on otherwise blank lines (e.g., around this section). Spotless is configured with trimTrailingWhitespace, so this will fail formatting checks in CI; please run mvn spotless:apply or remove the trailing spaces.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied. Spotless formatting has been run to remove trailing whitespace and fix all formatting issues. Commit eb573ef

Comment on lines 63 to 78
void sessionConfigListIndependence() {
SessionConfig original = new SessionConfig();
List<String> toolList = new ArrayList<>();
toolList.add("grep");
toolList.add("bash");
original.setAvailableTools(toolList);

SessionConfig cloned = original.clone();

List<String> clonedTools = new ArrayList<>(cloned.getAvailableTools());
clonedTools.add("web");
cloned.setAvailableTools(clonedTools);

assertEquals(2, original.getAvailableTools().size());
assertEquals(3, cloned.getAvailableTools().size());
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

sessionConfigListIndependence() doesn’t currently validate that SessionConfig.clone() actually copies the underlying availableTools list: it builds a new list from the clone and sets it back, which would still pass even if the clone shared the original list. To test clone semantics, mutate the original list instance (toolList) after cloning (or otherwise observe independence) and assert the cloned config is unaffected.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed test to properly validate list independence by mutating the original list after cloning and verifying the cloned config is unaffected. Commit eb573ef

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed test to properly validate list independence by mutating the original list after cloning and verifying the cloned config is unaffected. Commit 6e2e991

Comment on lines 327 to 351
/**
* Creates a shallow clone of this {@code CopilotClientOptions} instance.
* <p>
* Array properties (like {@code cliArgs}) are copied into new arrays so that
* modifications to the clone do not affect the original. Other reference-type
* properties (like {@code environment}) are shared between the original and
* clone.
*
* @return a clone of this options instance
*/
public CopilotClientOptions clone() {
CopilotClientOptions copy = new CopilotClientOptions();
copy.cliPath = this.cliPath;
copy.cliArgs = this.cliArgs != null ? this.cliArgs.clone() : null;
copy.cwd = this.cwd;
copy.port = this.port;
copy.useStdio = this.useStdio;
copy.cliUrl = this.cliUrl;
copy.logLevel = this.logLevel;
copy.autoStart = this.autoStart;
copy.autoRestart = this.autoRestart;
copy.environment = this.environment;
copy.githubToken = this.githubToken;
copy.useLoggedInUser = this.useLoggedInUser;
return copy;
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

CopilotClientOptions.clone() copies cliArgs but shares the mutable environment Map. Since getEnvironment()/setEnvironment() expose a modifiable Map and other config clone() methods copy their Map/List fields, sharing this Map makes it easy for changes on the clone to affect the original (and vice versa). Consider cloning the environment map as well (or, if sharing is intentional, document that as an exception and add a test to lock in the behavior).

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed to clone the environment map for collection independence. Updated Javadoc to reflect that the environment map is now copied. Added test copilotClientOptionsEnvironmentIndependence to validate this behavior. Commit eb573ef

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed to clone the environment map for collection independence. Updated Javadoc to reflect that the environment map is now copied. Added test copilotClientOptionsEnvironmentIndependence to validate this behavior. Commit 6e2e991

brunoborges and others added 4 commits February 17, 2026 08:31
…java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
brunoborges and others added 3 commits February 17, 2026 09:44
….java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
- Fix sessionConfigListIndependence test to properly validate list independence by mutating original list after cloning
- Clone environment map in CopilotClientOptions for collection independence
- Add copilotClientOptionsEnvironmentIndependence test to validate environment map cloning
- Update CopilotClientOptions Javadoc to reflect environment map is now copied
- Apply spotless formatting

Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Copy link
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

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@brunoborges brunoborges merged commit 639f2ee into main Feb 17, 2026
12 checks passed
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] 6 new commits (2026-02-17)

2 participants