Conversation
Add @github/copilot-sdk 0.1.23 as a production dependency. The SDK ships per-platform native CLI binaries (@github/copilot-darwin-arm64, etc.) that require build system support: - .moduleignore: strip copilot prebuilds/ripgrep/clipboard for other platforms - gulpfile.vscode.ts: filter wrong-arch platform packages, ASAR-unpack binaries - darwin/create-universal-app.ts: copy missing arch package for universal merger - darwin/sign.ts: custom entitlements for the copilot CLI binary - darwin/verify-macho.ts: skip copilot binaries in arch verification - next/index.ts: add copilotSdkHost as a utility process entry point
Add 'sessions-sdk' to NativeParsedArgs and the OPTIONS descriptor so it can be passed on the command line (e.g. ./scripts/code.sh --sessions-sdk). Add isSessionsSdkWindow to IWorkbenchEnvironmentService so renderer code can check whether the SDK backend is active. Browser returns false; native reads from the window configuration.
Three-layer architecture for the Copilot SDK integration: 1. common/copilotSdkService.ts — ICopilotSdkService interface with session CRUD, messaging, events, model listing, and auth. All IPC types defined here so both main and renderer can reference them. 2. electron-main/copilotSdkStarter.ts — CopilotSdkMainService that lazily spawns a UtilityProcess on first use, connects via MessagePort, and exposes an IServerChannel. Follows the pty host pattern. 3. node/copilotSdkHost.ts — Utility process entry point that wraps the @github/copilot-sdk CopilotClient. Implements ICopilotSdkService so ProxyChannel.fromService() auto-generates the IPC channel. Resolves the bundled CLI binary, builds a clean env, and forwards all events.
Register CopilotSdkMainService and its IPC channel in the main process, gated behind args[sessions-sdk] so no utility process is spawned or DI service created during normal VS Code usage. - app.ts: conditional DI registration + channel setup + window open logic - chat.contribution.ts: register SdkChatViewPane when isSessionsSdkWindow - sessions.desktop.main.ts: import copilotSdkService renderer proxy
fc19eff to
9644090
Compare
src/vs/sessions/contrib/copilotSdk/browser/widget/sdkContentPartRenderer.ts
Show resolved
Hide resolved
Code Review — All Threads AddressedAll actionable feedback has been fixed. Resolving threads now. ✅ Fixed (16 threads)
🔇 Won't Fix / False Positive (5 threads)
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 35 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/vs/platform/copilotSdk/node/copilotSdkHost.ts:398
_attachSessionEvents()unconditionally creates a newDisposableStoreand overwrites_sessionDisposablesforsessionIdwithout disposing any existing store. IfresumeSession()is called multiple times for the same session, this will leak listeners. Dispose the existing store (if any) before replacing it.
private _attachSessionEvents(session: CopilotSession): void {
const sessionId = session.sessionId;
const store = new DisposableStore();
const listener = session.on((event: SessionEvent) => {
this._onSessionEvent.fire({
sessionId,
type: event.type as ICopilotSessionEvent['type'],
data: (event as { data?: Record<string, unknown> }).data ?? {},
});
});
store.add(typeof listener === 'function' ? toDisposable(listener) : listener);
this._sessionDisposables.set(sessionId, store);
}
There was a problem hiding this comment.
I left some initial high level feedback for the areas I felt I can provide it and ignored changes to vs/sessions for now and also did not yet drill into the utility process specifics.
I want @deepak1556 to comment on the build changes, the entitlements and the platform specific modules. Is the SDK really built natively for different platforms? I was hoping for a JS library, but maybe that is not the case.
On a high level I feel the direction of mixing both the architectural change (to move to utility process) and introducing entire new UI components for chat (which are not compatible to the old UI) the wrong approach. I would like us to:
- have 1 PR with the architectural change of a utility process and using SDK compatible with the old UI
- have 1 PR with exploring to recreate the chat rendering UI on top of the architectural changes
src/vs/workbench/services/environment/browser/environmentService.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/environment/common/environmentService.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/environment/electron-browser/environmentService.ts
Outdated
Show resolved
Hide resolved
bpasero
left a comment
There was a problem hiding this comment.
Many unresolved Copilot code feedback comments and 1 comment from me.
| server.registerChannel(CopilotSdkChannel, channel); | ||
| process.stderr.write(`[CopilotSdkHost] Channel '${CopilotSdkChannel}' registered on server\n`); | ||
|
|
||
| process.once('exit', () => { |
There was a problem hiding this comment.
Are we certain this works? At this moment the process is stopping and you are calling a long running operation?
deepak1556
left a comment
There was a problem hiding this comment.
Sorry for the late review, the comments can be addressed as followup
| <true/> | ||
| <key>com.apple.security.cs.allow-unsigned-executable-memory</key> | ||
| <true/> | ||
| <key>com.apple.security.automation.apple-events</key> |
There was a problem hiding this comment.
Is the apple events needed ?
% codesign -d --entitlements :- ~/Downloads/copilot
Executable=/Users/demohan/Downloads/copilot
warning: Specifying ':' in the path is deprecated and will not work in a future release
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>com.apple.security.cs.allow-jit</key><true/><key>com.apple.security.cs.allow-unsigned-executable-memory</key><true/><key>com.apple.security.cs.disable-library-validation</key><true/></dict></plist>
For the other 3 the utility process is already signed with the same set https://github.com/microsoft/vscode/blob/main/build/azure-pipelines/darwin/helper-plugin-entitlements.plist , so copliot cli launched from the process should inherit it by default.
Tl:dr, if the apple events is not needed can we remove this entitlement file in favor inheritance.
| } else if (fs.existsSync(inArm64U) && !fs.existsSync(inX64U)) { | ||
| fs.mkdirSync(path.dirname(inX64U), { recursive: true }); | ||
| fs.cpSync(inArm64U, inX64U, { recursive: true }); | ||
| } |
There was a problem hiding this comment.
Hmm can you remove the platform specific suffix and keep it as @github/copilot then we would just merge the binaries without having to do the above workaround.
| type: 'copilotSdkHost', | ||
| name: 'copilot-sdk-host', | ||
| entryPoint: 'vs/sessions/services/copilotSdk/node/copilotSdkHost', | ||
| args: ['--logsPath', this._environmentMainService.logsHome.with({ scheme: Schemas.file }).fsPath, '--disable-gpu'], |
| delete cliEnv['__CFBundleIdentifier']; | ||
| delete cliEnv['APP_SANDBOX_CONTAINER_ID']; |
There was a problem hiding this comment.
APP_SANDBOX_CONTAINER_ID is for apps from mac app store relying on the mac container sandbox, which our app doesn't, can be removed
launch withcode --sessions-utility-processrelated https://github.com/microsoft/vscode-internalbacklog/issues/6848