mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-07-26 09:24:35 +00:00
fix(cli): clarify memory folder opener behavior
This commit is contained in:
parent
4bd5e1f6e1
commit
90ae7fdb83
2 changed files with 15 additions and 4 deletions
|
|
@ -81,6 +81,10 @@ const mockedFs = vi.mocked(fs);
|
|||
const originalPlatform = process.platform;
|
||||
|
||||
type MockSpawnChild = EventEmitter & { unref: ReturnType<typeof vi.fn> };
|
||||
const folderOpenCommandByPlatform: Partial<Record<NodeJS.Platform, string>> = {
|
||||
darwin: 'open',
|
||||
win32: 'explorer',
|
||||
};
|
||||
|
||||
function createMockSpawnChild(
|
||||
event: 'spawn' | 'error' = 'spawn',
|
||||
|
|
@ -101,6 +105,10 @@ function stubPlatform(platform: NodeJS.Platform): void {
|
|||
});
|
||||
}
|
||||
|
||||
function expectedFolderOpenCommand(platform = process.platform): string {
|
||||
return folderOpenCommandByPlatform[platform] ?? 'xdg-open';
|
||||
}
|
||||
|
||||
describe('MemoryDialog', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
|
@ -172,7 +180,7 @@ describe('MemoryDialog', () => {
|
|||
});
|
||||
|
||||
expect(mockedSpawn).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
expectedFolderOpenCommand(),
|
||||
[path.join(os.homedir(), '.qwen-memory-test', 'memories')],
|
||||
expect.objectContaining({ detached: true, stdio: 'ignore' }),
|
||||
);
|
||||
|
|
@ -208,7 +216,7 @@ describe('MemoryDialog', () => {
|
|||
});
|
||||
|
||||
expect(mockedSpawn).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
expectedFolderOpenCommand(platform),
|
||||
[path.join(os.homedir(), '.qwen-memory-test', 'memories')],
|
||||
expect.objectContaining({ detached: true, stdio: 'ignore' }),
|
||||
);
|
||||
|
|
@ -238,7 +246,7 @@ describe('MemoryDialog', () => {
|
|||
});
|
||||
|
||||
expect(mockedSpawn).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
expectedFolderOpenCommand(),
|
||||
[getAutoMemoryRoot('/tmp/project')],
|
||||
expect.objectContaining({ detached: true, stdio: 'ignore' }),
|
||||
);
|
||||
|
|
@ -258,7 +266,7 @@ describe('MemoryDialog', () => {
|
|||
});
|
||||
|
||||
expect(mockedSpawn).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
expectedFolderOpenCommand(),
|
||||
[getAutoMemoryRoot('/tmp/project')],
|
||||
expect.objectContaining({ detached: true, stdio: 'ignore' }),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ async function openFolderPath(folderPath: string): Promise<void> {
|
|||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
child.once('error', reject);
|
||||
// Exit codes are intentionally not observed: the folder opener is
|
||||
// fire-and-forget, and waiting for exit can block until the file manager
|
||||
// closes.
|
||||
child.once('spawn', () => resolve());
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue