mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-16 06:01:57 +00:00
数据目录阶段 1B 前端:画布和问数据页的过程里显示「参考了 N 张表」,展开按数据源列出表名,挑表失败时写明只提供了表名及原因
This commit is contained in:
@@ -472,6 +472,9 @@ async function fakeApi(route) {
|
||||
}
|
||||
const ops = [
|
||||
{ op: 'heartbeat', phase: 'planning', elapsed_ms: 800 },
|
||||
// 服务端按需求挑了表(copilot_context):过程里多一行「参考了 N 张表」
|
||||
{ op: 'context', elapsed_ms: 1200, sources: [
|
||||
{ source: 'shop', tables: ['orders', 'order_items'], selected_by: 'model', total: 48 }] },
|
||||
{ op: 'plan', summary: '查一下再回答' },
|
||||
...GRAPH.nodes.map((n) => ({ op: 'add_node', node: n })),
|
||||
{ op: 'done', explanation: '一张三步的图' },
|
||||
@@ -1024,6 +1027,16 @@ for (const theme of THEMES) {
|
||||
check('完整答案取到了,meta 里没有「没取全」', !meta?.clipped, JSON.stringify(meta?.clipped))
|
||||
await page.getByText('展开全部').first().click().catch(() => {})
|
||||
check('完整结尾在页面上', await shows(page, '【完整结尾】'))
|
||||
// 建图时服务端说了这一轮参考了哪些表:收在「规划」里,点开是一行,再点开看表名
|
||||
check('建图的 context 操作原样记进这一轮', t.ops.some((o) => o.op === 'context'))
|
||||
const turnCard = page.locator('[data-turn]').last()
|
||||
await turnCard.locator('button', { hasText: '规划' }).first().click()
|
||||
const ctxRow = turnCard.locator('[data-step-code="copilot_context"]')
|
||||
check('点开「规划」看到参考了几张表', await ctxRow.waitFor({ timeout: 3000 }).then(() => true, () => false)
|
||||
&& (await ctxRow.innerText()).includes('参考了 2 张表'))
|
||||
await ctxRow.locator('button').first().click()
|
||||
check('再点开看到按数据源分组的表名', await ctxRow.getByText('「shop」按需求从 48 张表中挑出 2 张:orders、order_items')
|
||||
.waitFor({ timeout: 3000 }).then(() => true, () => false))
|
||||
check('没有运行时报错', errors.length === 0, errors[0] ?? '')
|
||||
await ctx.close()
|
||||
})
|
||||
|
||||
@@ -621,6 +621,49 @@ await section('从 SQL 认表名', async () => {
|
||||
check('不是查询就不硬认', g('这不是 SQL') === null)
|
||||
})
|
||||
|
||||
await section('Copilot:这一轮参考了哪些表(context 操作)', async () => {
|
||||
// 大库先按需求挑表,挑中的表给模型全部字段。生成的 SQL 用错了表时,先得知道模型当时看到的是哪几张
|
||||
const steps = mod.decodeCopilot(synthetic.COPILOT_CONTEXT, { context: 'canvas' })
|
||||
const row = steps.find((s) => s.code === 'copilot_context')
|
||||
check('一行说清参考了几张表', row?.title === '参考了 5 张表', row?.title)
|
||||
check('展开按数据源分组列出表名', !!row?.detail?.includes('「scenic」按需求从 51 张表中挑出 3 张:visits、channels、channel_visits')
|
||||
&& row.detail.includes('「shop」全部 2 张表:orders、customers'), row?.detail)
|
||||
check('挑表的耗时挂在行尾', row?.ms === 3420 && !!row?.meta, `${row?.ms} ${row?.meta}`)
|
||||
check('是看表结构那一类、标着规划阶段', row?.kind === 'schema' && row?.stage === 'plan' && row?.status === 'done')
|
||||
check('排在思考之前,心跳仍然只更新那一条阶段行',
|
||||
steps.indexOf(row) < steps.findIndex((s) => s.kind === 'think')
|
||||
&& steps.filter((s) => s.kind === 'lifecycle' && s.id.startsWith('hb-')).length === 1,
|
||||
steps.map((s) => `${s.kind}:${s.title}`).join(' | '))
|
||||
check('收尾后没有还在转的行', !steps.some((s) => s.status === 'running'),
|
||||
steps.filter((s) => s.status === 'running').map((s) => s.title).join(','))
|
||||
check('结局不受影响', mod.copilotOutcome(synthetic.COPILOT_CONTEXT).kind === 'built')
|
||||
|
||||
const fb = mod.decodeCopilot(synthetic.COPILOT_CONTEXT_FALLBACK, { context: 'chat' }).find((s) => s.code === 'copilot_context')
|
||||
check('挑表失败:标题直说只给了表名', fb?.title === '未能按需求挑选,已提供全部表名', fb?.title)
|
||||
check('挑表失败:原因和库的规模放在展开区', !!fb?.detail?.includes('原因:挑选数据表超过 20 秒未完成')
|
||||
&& fb.detail.includes('「scenic」共 51 张表'), fb?.detail)
|
||||
check('挑表失败也说等了多久', fb?.ms === 20004, String(fb?.ms))
|
||||
|
||||
const seeded = mod.copilotContext({ op: 'context', sources: [
|
||||
{ source: 'scenic', tables: ['stores'], selected_by: 'fallback', total: 51, reason: '模型未挑出任何表' }] })
|
||||
check('没挑成但现有工作流的表带着字段:标题说几张、副标题说没挑成',
|
||||
seeded?.title === '参考了 1 张表' && seeded?.sub === '未能按需求挑选,已提供全部表名'
|
||||
&& seeded.detail.includes('现有工作流用到的 1 张表附带全部字段:stores'), JSON.stringify(seeded))
|
||||
const mixed = mod.copilotContext({ op: 'context', sources: [
|
||||
{ source: 'a', tables: ['x'], selected_by: 'all', total: 1 },
|
||||
{ source: 'b', tables: [], selected_by: 'fallback', total: 80, reason: 'r' }] })
|
||||
check('只有一个库没挑成:副标题点名是哪个库', mixed?.sub === '「b」未能按需求挑选,已提供全部表名', mixed?.sub)
|
||||
const none = mod.copilotContext({ op: 'context', sources: [
|
||||
{ source: 'a', tables: ['x'], selected_by: 'model', total: 60 },
|
||||
{ source: 'b', tables: [], selected_by: 'model', total: 70 }] })
|
||||
check('挑表成功但某个库一张没挑中:说清只给了表名', !!none?.detail.includes('「b」共 70 张表,未挑中与需求相关的表,已提供全部表名'),
|
||||
none?.detail)
|
||||
check('形状不对不出行、不报错', mod.decodeCopilot([
|
||||
{ op: 'context' }, { op: 'context', sources: 'x' }, { op: 'context', sources: [null, 3, { tables: ['t'] }] },
|
||||
]).length === 0)
|
||||
check('认不出的操作照旧忽略', mod.decodeCopilot([{ op: 'something_new', x: 1 }]).length === 0)
|
||||
})
|
||||
|
||||
await section('Copilot:心跳穿插、回话、少了一步、报错', async () => {
|
||||
const steps = mod.decodeCopilot(synthetic.COPILOT_STUCK, { context: 'canvas' })
|
||||
check('心跳穿插的思考仍然并成一条', steps.filter((s) => s.kind === 'think').length === 1,
|
||||
|
||||
@@ -694,6 +694,43 @@ await section('长表名、Copilot 结局、问数据的分段', async () => {
|
||||
await q.page.close()
|
||||
})
|
||||
|
||||
await section('参考了哪些表:画布右栏和问数据页(context 操作)', async () => {
|
||||
const c = await open('syn=copilot-context&dense=1', { w: 380, h: 800, name: 'copilot-context' })
|
||||
const row = c.page.locator('[data-step-code="copilot_context"]')
|
||||
check('画布右栏:一行说参考了几张表', await row.count() === 1 && (await row.innerText()).includes('参考了 5 张表'),
|
||||
await row.count() ? await row.innerText() : '没有这一行')
|
||||
check('表名收在展开区,不铺满窄栏', !(await row.innerText()).includes('channel_visits'))
|
||||
await row.locator('button').first().click()
|
||||
await c.page.waitForTimeout(150)
|
||||
const expanded = await row.innerText()
|
||||
check('展开看到按数据源分组的表名', expanded.includes('「scenic」按需求从 51 张表中挑出 3 张')
|
||||
&& expanded.includes('channel_visits') && expanded.includes('「shop」全部 2 张表'), expanded.slice(0, 160))
|
||||
const overflow = await c.page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)
|
||||
check('展开后不撑破 380px 窄栏', overflow <= 0, `${overflow}px`)
|
||||
check('没有运行时报错', c.errors.length === 0, c.errors.join(' | '))
|
||||
await c.page.close()
|
||||
|
||||
const f = await open('syn=copilot-fallback&dense=1', { w: 380, h: 800, name: 'copilot-fallback' })
|
||||
const fb = f.page.locator('[data-step-code="copilot_context"]')
|
||||
check('挑表失败:写明只给了表名', await fb.count() === 1 && (await fb.innerText()).includes('未能按需求挑选,已提供全部表名'))
|
||||
await fb.locator('button').first().click()
|
||||
await f.page.waitForTimeout(150)
|
||||
check('挑表失败:展开看到原因', (await fb.innerText()).includes('原因:挑选数据表超过 20 秒未完成'))
|
||||
await f.page.close()
|
||||
|
||||
const q = await open('syn=chat', { w: 1100, h: 800, name: 'chat-context' })
|
||||
check('问数据页:执行开始后这一行随「规划」收起', !(await q.page.locator('body').innerText()).includes('参考了 2 张表'))
|
||||
await q.page.locator('button', { hasText: '规划' }).first().click()
|
||||
await q.page.waitForTimeout(200)
|
||||
const qrow = q.page.locator('[data-step-code="copilot_context"]')
|
||||
check('问数据页:点开「规划」看到参考了几张表', await qrow.count() === 1 && (await qrow.innerText()).includes('参考了 2 张表'))
|
||||
await qrow.locator('button').first().click()
|
||||
await q.page.waitForTimeout(150)
|
||||
check('问数据页:展开看到表名', (await qrow.innerText()).includes('v_device_kpi、dim_device'))
|
||||
check('问数据页:没有运行时报错', q.errors.length === 0, q.errors.join(' | '))
|
||||
await q.page.close()
|
||||
})
|
||||
|
||||
await section('步骤行和画布联动', async () => {
|
||||
const { page } = await open('syn=mixed&link=1', { w: 1100, h: 800 })
|
||||
const row = page.locator('[data-node-id="agent"]').first()
|
||||
|
||||
@@ -1025,6 +1025,9 @@ await section('助手改图:一步撤销、回执、只回话、失败退回
|
||||
}
|
||||
state.stream = [
|
||||
{ op: 'model', model: 'fake-model' },
|
||||
// 服务端按需求挑了表(copilot_context):过程里多一行「参考了 N 张表」
|
||||
{ op: 'context', elapsed_ms: 1500, sources: [
|
||||
{ source: 'shop', tables: ['orders', 'order_items', 'customers'], selected_by: 'model', total: 48 }] },
|
||||
{ op: 'plan', summary: '加一步润色' },
|
||||
{ op: 'update_node', id: 'answer', config: finalGraph.nodes[3].data.config },
|
||||
{ op: 'add_node', node: { id: 'polish', type: 'llm', label: '润色', config: { prompt: '{{ nodes.answer.text }}' } } },
|
||||
@@ -1041,6 +1044,12 @@ await section('助手改图:一步撤销、回执、只回话、失败退回
|
||||
const t1 = await S(page, () => window.__studio.getState().copilotTurns.at(-1))
|
||||
check('开始了就告诉输入框(runCopilot 返回 true)', began === true, String(began))
|
||||
check('收到 final:这一轮是「已应用」', t1.outcome === 'applied', t1.outcome)
|
||||
const ctxRow = page.locator('[data-step-code="copilot_context"]').last()
|
||||
check('助手栏的过程里一行说参考了几张表', await ctxRow.waitFor({ timeout: 3000 }).then(() => true, () => false)
|
||||
&& (await ctxRow.innerText()).includes('参考了 3 张表'))
|
||||
await ctxRow.locator('button').first().click()
|
||||
check('点开看到按数据源分组的表名', await ctxRow.getByText('「shop」按需求从 48 张表中挑出 3 张:orders、order_items、customers')
|
||||
.waitFor({ timeout: 3000 }).then(() => true, () => false))
|
||||
check('diff 记下新增和改动', t1.diff?.added.includes('polish') && t1.diff?.changed.includes('answer'), JSON.stringify(t1.diff))
|
||||
check('final.issues 进了这一轮(少了一步)', t1.issues?.some((i) => i.code === 'unknown_node_type'))
|
||||
const pos1 = await S(page, () => Object.fromEntries(window.__studio.getState().nodes.map((n) => [n.id, n.position])))
|
||||
|
||||
Reference in New Issue
Block a user