Skip to content

IAV-856/Refactor: Unify Main/Sub Agent Wizard into single module with bug fixes

salaheddine zidani a demandé de fusionner feature/IAV-856 vers develop

Summary

Consolidates the Agent Wizard module by merging the separate Main Agent and Sub Agent wizard layers (controllers, services, paths) into a single unified module. This also fixes several critical bugs identified during the previous code review.

Motivation

The previous architecture had two parallel controller/service/path stacks (Main + Sub) that shared ~80% of the same logic. This caused significant code duplication — especially in initialization methods (languages, standard instructions, working hours) — and made the codebase harder to maintain. Additionally, several bugs were present in the old code that could cause runtime failures.

What changed

Architecture (refactor)

  • Controller: MainAgentWizardController + SubAgentWizardControllerAgentWizardController
  • Service: MainAgentWizardService + SubAgentWizardServiceAgentWizardService
  • Paths: 3 path classes → 1 unified AgentWizardPaths
  • Common service: AgentWizardCommonService / AgentWizardCommonServiceImpl — unchanged

API changes

Before After
POST /main-agent-wizard/company-context POST /agent-wizard/main-agent/company-context
PUT /sub-agent-wizard/{subAgentUid}/company-context POST /agent-wizard/sub-agent/company-context
GET /main-agent-wizard/company-context (via x-user-uid) GET /agent-wizard/{agentUid}/company-context
GET /sub-agent-wizard/{subAgentUid}/company-context GET /agent-wizard/{agentUid}/company-context

Bug fixes

  1. Optional.get() without check — replaced with isEmpty() guard to prevent NoSuchElementException
  2. Missing parentAgent on sub-agent creation — now sets .parentAgent(mainAgent) in builder
  3. Wrong parameter in initializeAgentWorkingHours — now receives CustomerCareAgent entity directly instead of a UID string that would fail lookup
  4. Added outboundMessageWebhookUrl default value on agent creation

Testing

  • Main agent wizard full flow (create + all steps)
  • Sub-agent wizard full flow (create + all steps)
  • Company context GET by agentUid (both main and sub)
  • Verify sub-agent has parentAgent set after creation
  • Verify working hours initialization works for both agent types

Closes IAV-856

Modification effectuée par oussama aftys

Rapports de requête de fusion