mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-22 09:47:47 +00:00
remove pid from lockfile name of ide connection file
This commit is contained in:
@@ -133,13 +133,14 @@ describe('IDEServer', () => {
|
||||
'/home/test',
|
||||
'.qwen',
|
||||
'ide',
|
||||
`${process.ppid}-${port}.lock`,
|
||||
`${port}.lock`,
|
||||
);
|
||||
const expectedContent = JSON.stringify({
|
||||
port: parseInt(port, 10),
|
||||
workspacePath: expectedWorkspacePaths,
|
||||
ppid: process.ppid,
|
||||
authToken: 'test-auth-token',
|
||||
ideName: 'VS Code',
|
||||
});
|
||||
expect(fs.writeFile).toHaveBeenCalledWith(
|
||||
expectedLockFile,
|
||||
@@ -164,13 +165,14 @@ describe('IDEServer', () => {
|
||||
'/home/test',
|
||||
'.qwen',
|
||||
'ide',
|
||||
`${process.ppid}-${port}.lock`,
|
||||
`${port}.lock`,
|
||||
);
|
||||
const expectedContent = JSON.stringify({
|
||||
port: parseInt(port, 10),
|
||||
workspacePath: '/foo/bar',
|
||||
ppid: process.ppid,
|
||||
authToken: 'test-auth-token',
|
||||
ideName: 'VS Code',
|
||||
});
|
||||
expect(fs.writeFile).toHaveBeenCalledWith(
|
||||
expectedLockFile,
|
||||
@@ -195,13 +197,14 @@ describe('IDEServer', () => {
|
||||
'/home/test',
|
||||
'.qwen',
|
||||
'ide',
|
||||
`${process.ppid}-${port}.lock`,
|
||||
`${port}.lock`,
|
||||
);
|
||||
const expectedContent = JSON.stringify({
|
||||
port: parseInt(port, 10),
|
||||
workspacePath: '',
|
||||
ppid: process.ppid,
|
||||
authToken: 'test-auth-token',
|
||||
ideName: 'VS Code',
|
||||
});
|
||||
expect(fs.writeFile).toHaveBeenCalledWith(
|
||||
expectedLockFile,
|
||||
@@ -240,13 +243,14 @@ describe('IDEServer', () => {
|
||||
'/home/test',
|
||||
'.qwen',
|
||||
'ide',
|
||||
`${process.ppid}-${port}.lock`,
|
||||
`${port}.lock`,
|
||||
);
|
||||
const expectedContent = JSON.stringify({
|
||||
port: parseInt(port, 10),
|
||||
workspacePath: expectedWorkspacePaths,
|
||||
ppid: process.ppid,
|
||||
authToken: 'test-auth-token',
|
||||
ideName: 'VS Code',
|
||||
});
|
||||
expect(fs.writeFile).toHaveBeenCalledWith(
|
||||
expectedLockFile,
|
||||
@@ -267,6 +271,7 @@ describe('IDEServer', () => {
|
||||
workspacePath: '/baz/qux',
|
||||
ppid: process.ppid,
|
||||
authToken: 'test-auth-token',
|
||||
ideName: 'VS Code',
|
||||
});
|
||||
expect(fs.writeFile).toHaveBeenCalledWith(
|
||||
expectedLockFile,
|
||||
@@ -279,12 +284,7 @@ describe('IDEServer', () => {
|
||||
await ideServer.start(mockContext);
|
||||
const replaceMock = mockContext.environmentVariableCollection.replace;
|
||||
const port = getPortFromMock(replaceMock);
|
||||
const lockFile = path.join(
|
||||
'/home/test',
|
||||
'.qwen',
|
||||
'ide',
|
||||
`${process.ppid}-${port}.lock`,
|
||||
);
|
||||
const lockFile = path.join('/home/test', '.qwen', 'ide', `${port}.lock`);
|
||||
expect(fs.writeFile).toHaveBeenCalledWith(lockFile, expect.any(String));
|
||||
|
||||
await ideServer.stop();
|
||||
@@ -315,13 +315,14 @@ describe('IDEServer', () => {
|
||||
'/home/test',
|
||||
'.qwen',
|
||||
'ide',
|
||||
`${process.ppid}-${port}.lock`,
|
||||
`${port}.lock`,
|
||||
);
|
||||
const expectedContent = JSON.stringify({
|
||||
port: parseInt(port, 10),
|
||||
workspacePath: expectedWorkspacePaths,
|
||||
ppid: process.ppid,
|
||||
authToken: 'test-auth-token',
|
||||
ideName: 'VS Code',
|
||||
});
|
||||
expect(fs.writeFile).toHaveBeenCalledWith(
|
||||
expectedLockFile,
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
IdeContextNotificationSchema,
|
||||
OpenDiffRequestSchema,
|
||||
} from '@qwen-code/qwen-code-core/src/ide/types.js';
|
||||
import { detectIdeFromEnv } from '@qwen-code/qwen-code-core/src/ide/detect-ide.js';
|
||||
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
||||
@@ -82,11 +83,13 @@ async function writePortAndWorkspace({
|
||||
workspacePath,
|
||||
);
|
||||
|
||||
const ideInfo = detectIdeFromEnv();
|
||||
const content = JSON.stringify({
|
||||
port,
|
||||
workspacePath,
|
||||
ppid: process.ppid,
|
||||
authToken,
|
||||
ideName: ideInfo.displayName,
|
||||
});
|
||||
|
||||
log(`Writing IDE lock file to: ${lockFile}`);
|
||||
@@ -340,12 +343,8 @@ export class IDEServer {
|
||||
this.port = address.port;
|
||||
try {
|
||||
const ideDir = await getGlobalIdeDir();
|
||||
// Name the lock file by port to support multiple server instances
|
||||
// under the same parent process.
|
||||
this.lockFile = path.join(
|
||||
ideDir,
|
||||
`${process.ppid}-${this.port}.lock`,
|
||||
);
|
||||
// Name the lock file by port to support multiple server instances.
|
||||
this.lockFile = path.join(ideDir, `${this.port}.lock`);
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
this.log(`Failed to determine IDE lock directory: ${message}`);
|
||||
|
||||
Reference in New Issue
Block a user