Skip to content

Fixes #4977 terminal relaunch prompt by removing env-var injection#5189

Merged
ianhattendorf merged 2 commits into
mainfrom
4977-always-complaining-about-wanting-to-relaunch-terminal
May 5, 2026
Merged

Fixes #4977 terminal relaunch prompt by removing env-var injection#5189
ianhattendorf merged 2 commits into
mainfrom
4977-always-complaining-about-wanting-to-relaunch-terminal

Conversation

@ianhattendorf

@ianhattendorf ianhattendorf commented May 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Drops GK_GL_ADDR and GK_GL_PATH writes to EnvironmentVariableCollection in GkCliIntegrationProvider.start() / stop(). The writes were registered after container.onReady() resolved, so VS Code saw them as a late change against already-restored persistent terminals and surfaced the "Relaunch terminal" prompt. Since gitkraken.mcp.autoEnabled defaults to true, this fired for nearly every AI-enabled user.
  • Carries the discovery file path on the existing gk:cli:ipc:started event payload instead, and caches it on GkMcpProviderBase so the VS Code and Cursor MCP providers no longer round-trip through envVars.get('GK_GL_PATH'). MCP behavior is unchanged: the path is still forwarded to the spawned gk mcp server via McpStdioServerDefinition.env / cursor.mcp.registerServer({ env }).
  • Removes the now-redundant experimental gitlens.gitkraken.cli.integration.enabled setting; the integration's only remaining job is to power MCP, so the gate collapses to mcp.autoEnabled alone.

Trade-off: a gk CLI 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 — only GK_GL_ADDR-style env discovery is dropped. Per discussion, this terminal-side handoff is rarely used.

Test plan

  • pnpm run build is clean (already verified locally)
  • Reproduce relaunch prompt on main (persistent terminal open across a window reload, AI-enabled account) — confirm it appears
  • On this branch with the same setup, confirm the prompt no longer appears
  • Deterministic check: toggle gitlens.gitkraken.mcp.autoEnabled mid-session with a terminal already open — confirm no relaunch banner on this branch
  • VS Code 1.101+: GitKraken MCP server still registers via lm.registerMcpServerDefinitionProvider and tools respond
  • Cursor: GitKraken MCP server still registers via cursor.mcp.registerServer and tools respond
  • Output → "GitLens" channel still shows [IPC] Server started on ... when the gate is satisfied

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_PATH into the integrated terminal environment; emit the discovery file path via gk:cli:ipc:started instead.
  • Cache the discovery file path in GkMcpProviderBase and have VS Code/Cursor MCP providers read from that cache (no env-var roundtrip).
  • Remove the experimental gitlens.gitkraken.cli.integration.enabled setting and gate the integration on gitlens.gitkraken.mcp.autoEnabled only.

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 the EnvironmentVariableCollection, which is good for avoiding the relaunch prompt, but it also means consumers won’t automatically see GK_GL_PATH removed. Since MCP providers now rely on an in-memory cached discoveryFilePath, consider explicitly notifying them on stop (e.g., fire an IPC-stopped event or fire gk:cli:ipc:started with { 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.

Comment thread src/env/node/gk/mcp/integrationBase.ts
@ianhattendorf ianhattendorf marked this pull request as ready for review May 5, 2026 01:41
@augmentcode

augmentcode Bot commented May 5, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Removes terminal environment-variable injection for GitKraken CLI/MCP integration to stop VS Code from prompting users to relaunch persistent terminals (#4977).

Changes:

  • Stops writing GK_GL_ADDR/GK_GL_PATH into EnvironmentVariableCollection on IPC start/stop.
  • Includes the discovery file path in the existing gk:cli:ipc:started event payload and caches it in GkMcpProviderBase.
  • Updates VS Code + Cursor MCP providers to read the cached discovery path and forward it via MCP server env.
  • Removes the experimental gitlens.gitkraken.cli.integration.enabled setting and gates integration solely on gitkraken.mcp.autoEnabled.

Technical Notes: Event bus typing is updated to reflect the new gk:cli:ipc:started payload shape.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread package.json
@ianhattendorf ianhattendorf force-pushed the 4977-always-complaining-about-wanting-to-relaunch-terminal branch from a9a7d3f to d0ce13c Compare May 5, 2026 03:23
@ianhattendorf ianhattendorf force-pushed the 4977-always-complaining-about-wanting-to-relaunch-terminal branch from d0ce13c to 9f3c65b Compare May 5, 2026 03:55
@ianhattendorf ianhattendorf merged commit 3258869 into main May 5, 2026
7 checks passed
@ianhattendorf ianhattendorf deleted the 4977-always-complaining-about-wanting-to-relaunch-terminal branch May 5, 2026 04:08
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.

Always complaining about wanting to relaunch terminal

2 participants