feat: enrich listWaitingAgents with task/phase/initiative context via DB joins
Replaces the in-memory filter (agentManager.list() + filter) with a direct repository query that LEFT JOINs tasks, phases, and initiatives to return taskName, phaseName, initiativeName, and taskDescription alongside agent fields. - Adds AgentWithContext interface and findWaitingWithContext() to AgentRepository port - Implements findWaitingWithContext() in DrizzleAgentRepository using getTableColumns - Wires agentRepository into TRPCContext, CreateContextOptions, and TrpcAdapterOptions - Adds requireAgentRepository() helper following existing pattern - Updates listWaitingAgents to use repository query instead of agentManager - Adds 5 unit tests for findWaitingWithContext() covering all FK join edge cases - Updates existing AgentRepository mocks to satisfy updated interface Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import type { ConversationRepository } from '../db/repositories/conversation-rep
|
||||
import type { ChatSessionRepository } from '../db/repositories/chat-session-repository.js';
|
||||
import type { ReviewCommentRepository } from '../db/repositories/review-comment-repository.js';
|
||||
import type { ErrandRepository } from '../db/repositories/errand-repository.js';
|
||||
import type { AgentRepository } from '../db/repositories/agent-repository.js';
|
||||
import type { AccountCredentialManager } from '../agent/credentials/types.js';
|
||||
import type { DispatchManager, PhaseDispatchManager } from '../dispatch/types.js';
|
||||
import type { CoordinationManager } from '../coordination/types.js';
|
||||
@@ -87,6 +88,8 @@ export interface TRPCContext {
|
||||
projectSyncManager?: ProjectSyncManager;
|
||||
/** Absolute path to the workspace root (.cwrc directory) */
|
||||
workspaceRoot?: string;
|
||||
/** Agent repository for enriched queries (e.g., findWaitingWithContext) */
|
||||
agentRepository?: AgentRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,6 +122,7 @@ export interface CreateContextOptions {
|
||||
errandRepository?: ErrandRepository;
|
||||
projectSyncManager?: ProjectSyncManager;
|
||||
workspaceRoot?: string;
|
||||
agentRepository?: AgentRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,5 +159,6 @@ export function createContext(options: CreateContextOptions): TRPCContext {
|
||||
errandRepository: options.errandRepository,
|
||||
projectSyncManager: options.projectSyncManager,
|
||||
workspaceRoot: options.workspaceRoot,
|
||||
agentRepository: options.agentRepository,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user