Skip to content

Commit 0b04931

Browse files
committed
chore: merge task/todo-12-selectmcpjsondir-test — add unit tests for selectMcpJsonDir (TODO johannesjo#12)
1 parent 3606c5e commit 0b04931

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

electron/ipc/register.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { selectMcpJsonDir } from './register.js';
3+
4+
describe('selectMcpJsonDir', () => {
5+
it('returns worktreePath when defined', () => {
6+
expect(selectMcpJsonDir('/worktrees/my-task', '/project')).toBe('/worktrees/my-task');
7+
});
8+
9+
it('returns projectRoot when worktreePath is undefined', () => {
10+
expect(selectMcpJsonDir(undefined, '/project')).toBe('/project');
11+
});
12+
13+
it('returns empty string when worktreePath is empty string (nullish coalescing only catches null/undefined)', () => {
14+
expect(selectMcpJsonDir('', '/project')).toBe('');
15+
});
16+
});

src/store/tasks.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ vi.mock('./core', () => ({
5454
if (prop === 'agents') return mockAgents;
5555
if (prop === 'taskOrder') return mockTaskOrder;
5656
if (prop === 'collapsedTaskOrder') return [];
57+
if (prop === 'availableAgents') return [];
5758
return undefined;
5859
},
5960
}),

src/store/tasks.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -912,18 +912,22 @@ export function initMCPListeners(): () => void {
912912
skipPermissions: evt.skipPermissions ?? false,
913913
};
914914

915+
const cmd = evt.agentCommand ?? 'claude';
916+
const matchedDef = store.availableAgents?.find((a) => a.command === cmd);
917+
const agentDef = matchedDef ?? {
918+
id: cmd,
919+
name: cmd,
920+
command: cmd,
921+
args: evt.agentArgs ?? [],
922+
resume_args: [],
923+
skip_permissions_args: ['--dangerously-skip-permissions'],
924+
description: '',
925+
};
926+
915927
const agent: Agent = {
916928
id: evt.agentId,
917929
taskId: evt.taskId,
918-
def: {
919-
id: 'claude',
920-
name: 'Claude Code',
921-
command: evt.agentCommand ?? 'claude',
922-
args: evt.agentArgs ?? [],
923-
resume_args: [],
924-
skip_permissions_args: ['--dangerously-skip-permissions'],
925-
description: '',
926-
},
930+
def: matchedDef ? { ...matchedDef, args: evt.agentArgs ?? matchedDef.args } : agentDef,
927931
resumed: false,
928932
status: 'running',
929933
exitCode: null,

0 commit comments

Comments
 (0)