Skip to content

Commit 1e0eeeb

Browse files
committed
fix: support long macOS app names
1 parent 77586cb commit 1e0eeeb

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/mcp/tools/macos/__tests__/stop_mac_app.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ describe('stop_mac_app plugin', () => {
8888
);
8989

9090
expect(calls).toHaveLength(1);
91-
expect(calls[0]).toEqual(['pkill', '-x', '--', 'Brimday']);
92-
expect(calls[0]).not.toContain('-f');
91+
expect(calls[0]).toEqual(['pkill', '-f', '--', '^(.*/)?Brimday( |$)']);
9392
});
9493

9594
it('should preserve long app executable names', async () => {
@@ -107,7 +106,7 @@ describe('stop_mac_app plugin', () => {
107106
),
108107
);
109108

110-
expect(calls[0]).toEqual(['pkill', '-x', '--', 'ThisIsAVeryLongApplicationName']);
109+
expect(calls[0]).toEqual(['pkill', '-f', '--', '^(.*/)?ThisIsAVeryLongApplicationName( |$)']);
111110
});
112111

113112
it('should treat app names as literal process names', async () => {
@@ -125,7 +124,7 @@ describe('stop_mac_app plugin', () => {
125124
),
126125
);
127126

128-
expect(calls[0]).toEqual(['pkill', '-x', '--', '-Example\\.\\*\\[Test\\]']);
127+
expect(calls[0]).toEqual(['pkill', '-f', '--', '^(.*/)?-Example\\.\\*\\[Test\\]( |$)']);
129128
});
130129

131130
it('should prioritize processId over appName', async () => {

src/mcp/tools/macos/stop_mac_app.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ export function createStopMacAppExecutor(
8383
const command =
8484
params.processId !== undefined
8585
? ['kill', String(params.processId)]
86-
: ['pkill', '-x', '--', escapeExtendedRegularExpression(params.appName!)];
86+
: [
87+
'pkill',
88+
'-f',
89+
'--',
90+
`^(.*/)?${escapeExtendedRegularExpression(params.appName!)}( |$)`,
91+
];
8792
const result = await executor(command, 'Stop macOS App');
8893

8994
if (!result.success) {

0 commit comments

Comments
 (0)