Skip to content

Commit a20fdad

Browse files
committed
Fix codex agent cross-repo session matching
1 parent 4eb42a3 commit a20fdad

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

packages/agent-manager/src/__tests__/adapters/CodexAdapter.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,13 @@ describe('CodexAdapter', () => {
208208

209209
const agents = await adapter.detectAgents();
210210
expect(agents).toHaveLength(1);
211-
expect(agents[0].pid).toBe(105);
211+
expect(agents[0]).toMatchObject({
212+
pid: 105,
213+
name: 'repo-x',
214+
summary: 'Codex process running',
215+
projectPath: '/repo-x',
216+
});
217+
expect(agents[0].sessionId).toBe('pid-105');
212218
});
213219

214220
it('should list process when session metadata is unavailable', async () => {

packages/agent-manager/src/adapters/CodexAdapter.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ interface CodexSession {
4343
lastPayloadType?: string;
4444
}
4545

46-
type SessionMatchMode = 'cwd' | 'missing-cwd' | 'any';
46+
type SessionMatchMode = 'cwd' | 'missing-cwd';
4747

4848
export class CodexAdapter implements AgentAdapter {
4949
readonly type = 'codex' as const;
@@ -94,7 +94,7 @@ export class CodexAdapter implements AgentAdapter {
9494
const assignedPids = new Set<number>();
9595
const agents: AgentInfo[] = [];
9696

97-
// Match exact cwd first, then missing-cwd sessions, then any available session.
97+
// Match exact cwd first, then missing-cwd sessions.
9898
this.assignSessionsForMode(
9999
'cwd',
100100
codexProcesses,
@@ -113,15 +113,6 @@ export class CodexAdapter implements AgentAdapter {
113113
processStartByPid,
114114
agents,
115115
);
116-
this.assignSessionsForMode(
117-
'any',
118-
codexProcesses,
119-
sortedSessions,
120-
usedSessionIds,
121-
assignedPids,
122-
processStartByPid,
123-
agents,
124-
);
125116

126117
// Every running codex process should still be listed.
127118
for (const processInfo of codexProcesses) {
@@ -454,8 +445,6 @@ export class CodexAdapter implements AgentAdapter {
454445
if (mode === 'missing-cwd') {
455446
return !session.projectPath;
456447
}
457-
458-
return true;
459448
});
460449
}
461450

0 commit comments

Comments
 (0)