feat: execution filter by agentflow name (#5117)

* feat: Add agentflow name filter to executions page

- Add agentflow name text field to executions filter UI
- Implement backend filtering with case-insensitive partial matching
- Add database index on chat_flow.name for improved query performance
- Support filtering executions by agentflow name across all database types

* chore: Fix linting issues and remove screenshot

- Apply prettier formatting to migration files
- Fix formatting in executions service
- Remove accidentally committed screenshot file
This commit is contained in:
anatolii burtsev
2025-09-05 06:01:30 -07:00
committed by GitHub
parent 449e8113e0
commit 42fed5713e
11 changed files with 87 additions and 6 deletions
@@ -47,6 +47,7 @@ const getAllExecutions = async (req: Request, res: Response, next: NextFunction)
// Flow and session filters
if (req.query.agentflowId) filters.agentflowId = req.query.agentflowId as string
if (req.query.agentflowName) filters.agentflowName = req.query.agentflowName as string
if (req.query.sessionId) filters.sessionId = req.query.sessionId as string
// State filter
@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddChatFlowNameIndex1755748356008 implements MigrationInterface {
name = 'AddChatFlowNameIndex1755748356008'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE INDEX \`IDX_chatflow_name\` ON \`chat_flow\` (\`name\`)`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX \`IDX_chatflow_name\` ON \`chat_flow\``)
}
}
@@ -37,6 +37,7 @@ import { FixOpenSourceAssistantTable1743758056188 } from './1743758056188-FixOpe
import { AddErrorToEvaluationRun1744964560174 } from './1744964560174-AddErrorToEvaluationRun'
import { ModifyExecutionDataColumnType1747902489801 } from './1747902489801-ModifyExecutionDataColumnType'
import { ModifyChatflowType1755066758601 } from './1755066758601-ModifyChatflowType'
import { AddChatFlowNameIndex1755748356008 } from './1755748356008-AddChatFlowNameIndex'
import { AddAuthTables1720230151482 } from '../../../enterprise/database/migrations/mariadb/1720230151482-AddAuthTables'
import { AddWorkspace1725437498242 } from '../../../enterprise/database/migrations/mariadb/1725437498242-AddWorkspace'
@@ -100,5 +101,6 @@ export const mariadbMigrations = [
AddErrorToEvaluationRun1744964560174,
ExecutionLinkWorkspaceId1746862866554,
ModifyExecutionDataColumnType1747902489801,
ModifyChatflowType1755066758601
ModifyChatflowType1755066758601,
AddChatFlowNameIndex1755748356008
]
@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddChatFlowNameIndex1755748356008 implements MigrationInterface {
name = 'AddChatFlowNameIndex1755748356008'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE INDEX \`IDX_chatflow_name\` ON \`chat_flow\` (\`name\`)`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX \`IDX_chatflow_name\` ON \`chat_flow\``)
}
}
@@ -38,6 +38,7 @@ import { AddErrorToEvaluationRun1744964560174 } from './1744964560174-AddErrorTo
import { FixErrorsColumnInEvaluationRun1746437114935 } from './1746437114935-FixErrorsColumnInEvaluationRun'
import { ModifyExecutionDataColumnType1747902489801 } from './1747902489801-ModifyExecutionDataColumnType'
import { ModifyChatflowType1755066758601 } from './1755066758601-ModifyChatflowType'
import { AddChatFlowNameIndex1755748356008 } from './1755748356008-AddChatFlowNameIndex'
import { AddAuthTables1720230151482 } from '../../../enterprise/database/migrations/mysql/1720230151482-AddAuthTables'
import { AddWorkspace1720230151484 } from '../../../enterprise/database/migrations/mysql/1720230151484-AddWorkspace'
@@ -102,5 +103,6 @@ export const mysqlMigrations = [
FixErrorsColumnInEvaluationRun1746437114935,
ExecutionLinkWorkspaceId1746862866554,
ModifyExecutionDataColumnType1747902489801,
ModifyChatflowType1755066758601
ModifyChatflowType1755066758601,
AddChatFlowNameIndex1755748356008
]
@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddChatFlowNameIndex1755748356008 implements MigrationInterface {
name = 'AddChatFlowNameIndex1755748356008'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE INDEX "IDX_chatflow_name" ON "chat_flow" ("name")`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX "IDX_chatflow_name"`)
}
}
@@ -37,6 +37,7 @@ import { FixOpenSourceAssistantTable1743758056188 } from './1743758056188-FixOpe
import { AddErrorToEvaluationRun1744964560174 } from './1744964560174-AddErrorToEvaluationRun'
import { ModifyExecutionSessionIdFieldType1748450230238 } from './1748450230238-ModifyExecutionSessionIdFieldType'
import { ModifyChatflowType1755066758601 } from './1755066758601-ModifyChatflowType'
import { AddChatFlowNameIndex1755748356008 } from './1755748356008-AddChatFlowNameIndex'
import { AddAuthTables1720230151482 } from '../../../enterprise/database/migrations/postgres/1720230151482-AddAuthTables'
import { AddWorkspace1720230151484 } from '../../../enterprise/database/migrations/postgres/1720230151484-AddWorkspace'
@@ -100,5 +101,6 @@ export const postgresMigrations = [
AddErrorToEvaluationRun1744964560174,
ExecutionLinkWorkspaceId1746862866554,
ModifyExecutionSessionIdFieldType1748450230238,
ModifyChatflowType1755066758601
ModifyChatflowType1755066758601,
AddChatFlowNameIndex1755748356008
]
@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddChatFlowNameIndex1755748356008 implements MigrationInterface {
name = 'AddChatFlowNameIndex1755748356008'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE INDEX "IDX_chatflow_name" ON "chat_flow" ("name")`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX "IDX_chatflow_name"`)
}
}
@@ -35,6 +35,7 @@ import { AddExecutionEntity1738090872625 } from './1738090872625-AddExecutionEnt
import { FixOpenSourceAssistantTable1743758056188 } from './1743758056188-FixOpenSourceAssistantTable'
import { AddErrorToEvaluationRun1744964560174 } from './1744964560174-AddErrorToEvaluationRun'
import { ModifyChatflowType1755066758601 } from './1755066758601-ModifyChatflowType'
import { AddChatFlowNameIndex1755748356008 } from './1755748356008-AddChatFlowNameIndex'
import { AddAuthTables1720230151482 } from '../../../enterprise/database/migrations/sqlite/1720230151482-AddAuthTables'
import { AddWorkspace1720230151484 } from '../../../enterprise/database/migrations/sqlite/1720230151484-AddWorkspace'
@@ -96,5 +97,6 @@ export const sqliteMigrations = [
FixOpenSourceAssistantTable1743758056188,
AddErrorToEvaluationRun1744964560174,
ExecutionLinkWorkspaceId1746862866554,
ModifyChatflowType1755066758601
ModifyChatflowType1755066758601,
AddChatFlowNameIndex1755748356008
]
@@ -11,6 +11,7 @@ import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
export interface ExecutionFilters {
id?: string
agentflowId?: string
agentflowName?: string
sessionId?: string
state?: ExecutionState
startDate?: Date
@@ -65,7 +66,7 @@ const getPublicExecutionById = async (executionId: string): Promise<Execution |
const getAllExecutions = async (filters: ExecutionFilters = {}): Promise<{ data: Execution[]; total: number }> => {
try {
const appServer = getRunningExpressApp()
const { id, agentflowId, sessionId, state, startDate, endDate, page = 1, limit = 12, workspaceId } = filters
const { id, agentflowId, agentflowName, sessionId, state, startDate, endDate, page = 1, limit = 12, workspaceId } = filters
// Handle UUID fields properly using raw parameters to avoid type conversion issues
// This uses the query builder instead of direct objects for compatibility with UUID fields
@@ -78,6 +79,8 @@ const getAllExecutions = async (filters: ExecutionFilters = {}): Promise<{ data:
if (id) queryBuilder.andWhere('execution.id = :id', { id })
if (agentflowId) queryBuilder.andWhere('execution.agentflowId = :agentflowId', { agentflowId })
if (agentflowName)
queryBuilder.andWhere('LOWER(agentflow.name) LIKE LOWER(:agentflowName)', { agentflowName: `%${agentflowName}%` })
if (sessionId) queryBuilder.andWhere('execution.sessionId = :sessionId', { sessionId })
if (state) queryBuilder.andWhere('execution.state = :state', { state })
if (workspaceId) queryBuilder.andWhere('execution.workspaceId = :workspaceId', { workspaceId })
@@ -68,6 +68,7 @@ const AgentExecutions = () => {
startDate: null,
endDate: null,
agentflowId: '',
agentflowName: '',
sessionId: ''
})
@@ -132,6 +133,7 @@ const AgentExecutions = () => {
}
if (filters.agentflowId) params.agentflowId = filters.agentflowId
if (filters.agentflowName) params.agentflowName = filters.agentflowName
if (filters.sessionId) params.sessionId = filters.sessionId
getAllExecutions.request(params)
@@ -143,6 +145,7 @@ const AgentExecutions = () => {
startDate: null,
endDate: null,
agentflowId: '',
agentflowName: '',
sessionId: ''
})
setCurrentPage(1)
@@ -312,6 +315,20 @@ const AgentExecutions = () => {
}
/>
</Grid>
<Grid sx={{ ml: -1 }} item xs={12} md={2}>
<TextField
fullWidth
label='Agentflow'
value={filters.agentflowName}
onChange={(e) => handleFilterChange('agentflowName', e.target.value)}
size='small'
sx={{
'& .MuiOutlinedInput-notchedOutline': {
borderColor: borderColor
}
}}
/>
</Grid>
<Grid sx={{ ml: -1 }} item xs={12} md={2}>
<TextField
fullWidth
@@ -326,7 +343,7 @@ const AgentExecutions = () => {
}}
/>
</Grid>
<Grid item xs={12} md={4}>
<Grid item xs={12} md={2}>
<Stack direction='row' spacing={1}>
<Button
variant='contained'