Skip to content

refactor(mcp-server): remove TUI auto-launch from bootstrap and init #1113

Description

@JeremyDev87

Parent

Summary

Remove the launchAutoTui() function and its calls from the MCP server bootstrap (main.ts),
and remove the CODINGBUDDY_AUTO_TUI environment variable from init constants.

The TuiAutoLauncher class itself is kept — it's used by restart-tui.ts for the restart_tui MCP tool.

Files to Modify

1. apps/mcp-server/src/main.ts

Delete: launchAutoTui() function (lines 107–123)

// DELETE entire function (including JSDoc)
/**
 * Auto-launch TUI client in a new terminal window (non-blocking helper).
 * Extracted to avoid duplication between SSE and stdio modes.
 */
async function launchAutoTui(
  ipcServer: { clientCount(): number },
  tuiEnabled: boolean,
): Promise<void> {
  const { TuiAutoLauncher } = await import('./tui/ipc');
  const codingbuddyBin = path.resolve(process.argv[1]);
  const launcher = new TuiAutoLauncher({
    enabled: tuiEnabled || process.env.CODINGBUDDY_AUTO_TUI === '1',
    codingbuddyBin,
  });
  const result = await launcher.launch(ipcServer);
  debugLog(`TUI auto-launch: ${result.reason}${result.pid ? ` (PID: ${result.pid})` : ''}`);
}

Delete: SSE mode auto-launch call (lines 258–261)

// DELETE these lines (inside SSE mode try block, after ipcResult)
      // Auto-launch TUI client in a new terminal window (non-blocking)
      launchAutoTui(ipcResult.ipcServer, tuiEnabled).catch(err => {
        debugLog(`TUI auto-launch failed (non-blocking): ${err}`);
      });

Delete: stdio mode auto-launch call (lines 298–301)

// DELETE these lines (inside stdio mode try block, after ipcResult)
      // Auto-launch TUI client in a new terminal window (non-blocking)
      launchAutoTui(ipcResult.ipcServer, tuiEnabled).catch(err => {
        debugLog(`TUI auto-launch failed (non-blocking): ${err}`);
      });

2. apps/mcp-server/src/cli/init/init.constants.ts

Delete: CODINGBUDDY_AUTO_TUI entry (line 17)

// BEFORE:
export const CLAUDE_SETTINGS_ENV_ENTRIES: Record<string, string> = {
  ENABLE_TOOL_SEARCH: 'false',
  CODINGBUDDY_AUTO_TUI: '1',
};

// AFTER:
export const CLAUDE_SETTINGS_ENV_ENTRIES: Record<string, string> = {
  ENABLE_TOOL_SEARCH: 'false',
};

3. apps/mcp-server/src/cli/init/init.command.spec.ts

Update: Remove CODINGBUDDY_AUTO_TUI from assertions (lines 318, 378)

// BEFORE (two locations):
      expect(mockEnsureClaudeSettingsEnv).toHaveBeenCalledWith({
        ENABLE_TOOL_SEARCH: 'false',
        CODINGBUDDY_AUTO_TUI: '1',
      });

// AFTER (both locations):
      expect(mockEnsureClaudeSettingsEnv).toHaveBeenCalledWith({
        ENABLE_TOOL_SEARCH: 'false',
      });

DO NOT DELETE (Preserve These)

Item File Reason
TuiAutoLauncher class tui/ipc/tui-auto-launcher.ts Used by restart-tui.ts
TuiAutoLauncher export tui/ipc/index.ts:10-11 Required for restart-tui import
tui-auto-launcher.spec.ts Tests for the class Class still exists
initIpc() function main.ts IPC server needed for manual codingbuddy tui
restart-tui.ts CLI module restart_tui MCP tool still functional
restart-tui.spec.ts Tests for restart Still valid

Verification

# 1. TypeScript compilation
yarn workspace codingbuddy build

# 2. Run affected tests
yarn workspace codingbuddy test -- --testPathPattern="init.command"

# 3. No remaining launchAutoTui references
grep -rn "launchAutoTui" apps/mcp-server/src/

# 4. CODINGBUDDY_AUTO_TUI only in restart-tui (if at all)
grep -rn "CODINGBUDDY_AUTO_TUI" apps/mcp-server/src/

Acceptance Criteria

  • launchAutoTui() function removed from main.ts
  • SSE mode auto-launch call removed
  • stdio mode auto-launch call removed
  • CODINGBUDDY_AUTO_TUI: '1' removed from init.constants.ts
  • Test assertions updated in init.command.spec.ts
  • yarn workspace codingbuddy build passes
  • yarn workspace codingbuddy test -- --testPathPattern="init.command" passes
  • TuiAutoLauncher class and its tests still intact
  • restart-tui.ts still functional

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    mcp-serverapps/mcp-serverrefactorsub-issue상위 이슈의 하위 작업tuiTUI Agent Monitor

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions