Fixes #4977 terminal relaunch prompt by removing env-var injection#5189
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes late writes to VS Code’s EnvironmentVariableCollection from the GitKraken CLI integration to prevent the integrated terminal “Relaunch terminal” prompt, and shifts MCP discovery-path propagation to an internal event payload instead.
Changes:
- Stop injecting
GK_GL_ADDR/GK_GL_PATHinto the integrated terminal environment; emit the discovery file path viagk:cli:ipc:startedinstead. - Cache the discovery file path in
GkMcpProviderBaseand have VS Code/Cursor MCP providers read from that cache (no env-var roundtrip). - Remove the experimental
gitlens.gitkraken.cli.integration.enabledsetting and gate the integration ongitlens.gitkraken.mcp.autoEnabledonly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/eventBus.ts |
Changes gk:cli:ipc:started to carry a discovery file path payload. |
src/env/node/gk/mcp/integrationBase.ts |
Listens for the new payload and caches discoveryFilePath for MCP providers. |
src/env/node/gk/mcp/vscodeIntegration.ts |
Uses cached discovery path when building MCP server definitions. |
src/env/node/gk/mcp/cursorIntegration.ts |
Uses cached discovery path when registering the Cursor MCP server. |
src/env/node/gk/cli/integration.ts |
Removes env-var injection; emits discovery path on IPC start; removes old setting gate. |
package.json |
Removes the gitlens.gitkraken.cli.integration.enabled setting contribution. |
Comments suppressed due to low confidence (1)
src/env/node/gk/cli/integration.ts:201
stop()no longer clears theEnvironmentVariableCollection, which is good for avoiding the relaunch prompt, but it also means consumers won’t automatically seeGK_GL_PATHremoved. Since MCP providers now rely on an in-memory cacheddiscoveryFilePath, consider explicitly notifying them on stop (e.g., fire an IPC-stopped event or firegk:cli:ipc:startedwith{ discoveryFilePath: undefined }) so they don't keep using a deleted discovery file path.
private stop() {
// Cleanup discovery file
if (this._discoveryFilePath) {
void cleanupDiscoveryFile(this._discoveryFilePath);
this._discoveryFilePath = undefined;
}
if (this._runningDisposable != null) {
this._runningDisposable.dispose();
this._runningDisposable = undefined;
Logger.info(`${formatLoggableScopeBlock('IPC')} Server stopped`);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🤖 Augment PR SummarySummary: Removes terminal environment-variable injection for GitKraken CLI/MCP integration to stop VS Code from prompting users to relaunch persistent terminals (#4977). Changes:
Technical Notes: Event bus typing is updated to reflect the new 🤖 Was this summary useful? React with 👍 or 👎 |
a9a7d3f to
d0ce13c
Compare
d0ce13c to
9f3c65b
Compare
Summary
GK_GL_ADDRandGK_GL_PATHwrites toEnvironmentVariableCollectioninGkCliIntegrationProvider.start()/stop(). The writes were registered aftercontainer.onReady()resolved, so VS Code saw them as a late change against already-restored persistent terminals and surfaced the "Relaunch terminal" prompt. Sincegitkraken.mcp.autoEnableddefaults totrue, this fired for nearly every AI-enabled user.gk:cli:ipc:startedevent payload instead, and caches it onGkMcpProviderBaseso the VS Code and Cursor MCP providers no longer round-trip throughenvVars.get('GK_GL_PATH'). MCP behavior is unchanged: the path is still forwarded to the spawnedgk mcpserver viaMcpStdioServerDefinition.env/cursor.mcp.registerServer({ env }).gitlens.gitkraken.cli.integration.enabledsetting; the integration's only remaining job is to power MCP, so the gate collapses tomcp.autoEnabledalone.Trade-off: a
gkCLI invoked from a terminal no longer auto-discovers this VS Code window via env vars. The discovery file still exists at the well-known tmp path, so file-based discovery in the CLI is unaffected — onlyGK_GL_ADDR-style env discovery is dropped. Per discussion, this terminal-side handoff is rarely used.Test plan
pnpm run buildis clean (already verified locally)main(persistent terminal open across a window reload, AI-enabled account) — confirm it appearsgitlens.gitkraken.mcp.autoEnabledmid-session with a terminal already open — confirm no relaunch banner on this branchlm.registerMcpServerDefinitionProviderand tools respondcursor.mcp.registerServerand tools respond[IPC] Server started on ...when the gate is satisfied