Files
windmill/frontend/src/lib/components/raw_apps/utils.test.ts
T
centdixandClaude Opus 4.8 f86d0d79fc feat: add get_app_runtime_logs tool to global chat (#9502)
* feat: add get_app_runtime_logs tool to global chat

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: only handle raw app backend messages from the runner's own iframe

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat: add list_app_runs tool to global chat for raw app backend runs

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor: simplify raw app chat tool results

* nits

* nits

* chore: bump ui builder artifact

* fix: resolve pending runtime log requests on cleanup

* fix: harden raw app runtime log requests

* nits

* fix: show raw app tool results in status

* fix: cap raw app runtime log results

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 00:19:13 +02:00

64 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
formatRuntimeLogsForChat,
genWmillTs,
normalizeRawAppRuntimeLogs,
type Runnable
} from './utils'
const flowSchema = {
$schema: 'https://json-schema.org/draft/2020-12/schema',
type: 'object',
required: ['string_input'],
properties: {
string_input: {
type: 'string',
default: ''
},
count: {
type: 'integer'
}
}
} as const
describe('genWmillTs', () => {
it('generates the correct flow args type for path runnables', () => {
const runnables: Record<string, Runnable> = {
myflow: {
type: 'path',
runType: 'flow',
path: 'u/dev/my_flow',
name: 'My flow',
schema: flowSchema,
fields: {
count: {
type: 'static',
value: 1,
fieldType: 'number'
}
}
}
}
const dts = genWmillTs(runnables)
expect(dts).toContain('myflow: (args: { string_input: string }) => Promise<any>;')
})
})
describe('normalizeRawAppRuntimeLogs', () => {
it('keeps only well-formed runtime log entries', () => {
const entries = normalizeRawAppRuntimeLogs([
{ level: 'log', message: 'ready', ts: 1718000000000 },
{ level: 'trace', message: 'unsupported level', ts: 1718000000000 },
{ level: 'error', message: 'bad date', ts: Number.MAX_VALUE },
{ level: 'warn', message: 123, ts: 1718000000000 },
'not an entry'
])
expect(entries).toEqual([{ level: 'log', message: 'ready', ts: 1718000000000 }])
expect(formatRuntimeLogsForChat(entries)).toBe('[06:13:20.000] LOG: ready')
})
})