fix: UI crash on Reaction Logs — API returned 'logs' but UI expected 'reaction_logs'

Unified response key to reaction_logs in engine + tests + UI rebuild.

小橘 🍊(NEKO Team)
This commit is contained in:
小橘 2026-04-13 08:47:59 +00:00
parent 452bfba424
commit cdd735e018
2 changed files with 15 additions and 15 deletions

View File

@ -1342,7 +1342,7 @@ export async function listReactionLogs(
limit: number,
offset: number,
reactionId?: number,
): Promise<{ logs: ReactionLog[]; total: number }> {
): Promise<{ reaction_logs: ReactionLog[]; total: number }> {
let countQuery
if (reactionId !== undefined) {
countQuery = db.prepare('SELECT COUNT(*) as count FROM reaction_logs WHERE reaction_id = ?').bind(reactionId)
@ -1395,7 +1395,7 @@ export async function listReactionLogs(
created_at: row.created_at,
}))
return { logs, total }
return { reaction_logs: logs, total }
}
// ============================================

View File

@ -1707,8 +1707,8 @@ describe('Reaction Logs', () => {
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
expect(logsRes.status).toBe(200)
const logsJson = await logsRes.json()
expect(logsJson.logs.length).toBeGreaterThanOrEqual(1)
const successLog = logsJson.logs.find((l: any) => l.status === 'success')
expect(logsJson.reaction_logs.length).toBeGreaterThanOrEqual(1)
const successLog = logsJson.reaction_logs.find((l: any) => l.status === 'success')
expect(successLog).toBeDefined()
expect(successLog.projection_def).toBe('current_assignee')
expect(successLog.action).toBe('webhook')
@ -1728,7 +1728,7 @@ describe('Reaction Logs', () => {
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
const logsJson = await logsRes.json()
const skippedLog = logsJson.logs.find((l: any) => l.status === 'skipped')
const skippedLog = logsJson.reaction_logs.find((l: any) => l.status === 'skipped')
expect(skippedLog).toBeDefined()
})
@ -1741,7 +1741,7 @@ describe('Reaction Logs', () => {
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
const logsJson = await logsRes.json()
const log = logsJson.logs.find((l: any) => l.status === 'success')
const log = logsJson.reaction_logs.find((l: any) => l.status === 'success')
expect(log).toBeDefined()
expect(log.projection_def).toBe('current_assignee')
expect(log.old_value).toBe('')
@ -1761,15 +1761,15 @@ describe('Reaction Logs', () => {
API_TOKEN: API_TOKEN,
})
const filteredJson = await filteredRes.json()
expect(filteredJson.logs.length).toBeGreaterThanOrEqual(1)
expect(filteredJson.logs.every((l: any) => l.reaction_id === reactionId)).toBe(true)
expect(filteredJson.reaction_logs.length).toBeGreaterThanOrEqual(1)
expect(filteredJson.reaction_logs.every((l: any) => l.reaction_id === reactionId)).toBe(true)
const emptyRes = await app.fetch(req('GET', '/reaction-logs?reaction_id=99999'), {
DB: db,
API_TOKEN: API_TOKEN,
})
const emptyJson = await emptyRes.json()
expect(emptyJson.logs).toHaveLength(0)
expect(emptyJson.reaction_logs).toHaveLength(0)
expect(emptyJson.total).toBe(0)
})
})
@ -1859,7 +1859,7 @@ describe('Reaction Handler', () => {
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
const logsJson = await logsRes.json()
const successLog = logsJson.logs.find((l: any) => l.status === 'success')
const successLog = logsJson.reaction_logs.find((l: any) => l.status === 'success')
expect(successLog).toBeDefined()
expect(successLog.handler_output).toContain('old=')
expect(successLog.handler_output).toContain('new=')
@ -1894,7 +1894,7 @@ describe('Reaction Handler', () => {
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
const logsJson = await logsRes.json()
const successLog = logsJson.logs.find((l: any) => l.status === 'success' && l.action === 'handler')
const successLog = logsJson.reaction_logs.find((l: any) => l.status === 'success' && l.action === 'handler')
expect(successLog).toBeDefined()
expect(successLog.handler_output).toContain('emitted')
})
@ -1916,7 +1916,7 @@ describe('Reaction Handler', () => {
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
const logsJson = await logsRes.json()
const successLog = logsJson.logs.find((l: any) => l.status === 'success')
const successLog = logsJson.reaction_logs.find((l: any) => l.status === 'success')
expect(successLog).toBeDefined()
expect(successLog.handler_output).toContain('processed')
expect(successLog.handler_output).toContain('done')
@ -1946,7 +1946,7 @@ describe('Reaction Handler', () => {
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
const logsJson = await logsRes.json()
const handlerLogs = logsJson.logs.filter((l: any) => l.status === 'success' && l.action === 'handler')
const handlerLogs = logsJson.reaction_logs.filter((l: any) => l.status === 'success' && l.action === 'handler')
expect(handlerLogs.length).toBe(2)
const outputs = handlerLogs.map((l: any) => l.handler_output)
expect(outputs).toContain('count=1')
@ -1970,7 +1970,7 @@ describe('Reaction Handler', () => {
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
const logsJson = await logsRes.json()
const failedLog = logsJson.logs.find((l: any) => l.status === 'failed')
const failedLog = logsJson.reaction_logs.find((l: any) => l.status === 'failed')
expect(failedLog).toBeDefined()
expect(failedLog.handler_output).toContain('boom')
})
@ -1993,7 +1993,7 @@ describe('Reaction Handler', () => {
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
const logsJson = await logsRes.json()
const failedLog = logsJson.logs.find((l: any) => l.status === 'failed')
const failedLog = logsJson.reaction_logs.find((l: any) => l.status === 'failed')
expect(failedLog).toBeDefined()
expect(failedLog.handler_output).toContain('timeout')
}, 10000)