没有数据目录的大库:助手「参考了 N 张表」那一行提示先起草目录。真实运行里的大库一张目录都没有,挑表和 SQL 检查都用不上目录,用户也不知道该先去起草。服务端 context 操作的每个数据源多带 source_id 和 catalog_tables(去掉驳回项后还有内容的表数);前端 copilotContext 在要挑表的大库 catalog_tables 为 0 时给出下一步「这个数据源还没有数据目录,起草后挑表和 SQL 检查会更准」,入口直达 /data/catalog/:sourceId(几个库时点名,老服务端不给目录表数时不提示)。check-decode、check-stream、check-chat 补断言

This commit is contained in:
ThearchyHelios
2026-10-04 11:28:39 +08:00
parent f4a9955cc3
commit 546d0e9326
9 changed files with 138 additions and 20 deletions
+10 -1
View File
@@ -487,8 +487,10 @@ async function fakeApi(route) {
const ops = [
{ op: 'heartbeat', phase: 'planning', elapsed_ms: 800 },
// 服务端按需求挑了表(copilot_context):过程里多一行「参考了 N 张表」
// 这个库还没有数据目录(catalog_tables: 0):那一行下面提示先去起草目录
{ op: 'context', elapsed_ms: 1200, sources: [
{ source: 'shop', tables: ['orders', 'order_items'], selected_by: 'model', total: 48 }] },
{ source: 'shop', source_id: 'src-shop', tables: ['orders', 'order_items'], selected_by: 'model', total: 48,
catalog_tables: 0 }] },
{ op: 'plan', summary: '查一下再回答' },
...GRAPH.nodes.map((n) => ({ op: 'add_node', node: n })),
{ op: 'done', explanation: '一张三步的图' },
@@ -1069,6 +1071,13 @@ for (const theme of THEMES) {
await ctxRow.locator('button').first().click()
check('再点开看到按数据源分组的表名', await ctxRow.getByText('「shop」按需求从 48 张表中挑出 2 张:orders、order_items')
.waitFor({ timeout: 3000 }).then(() => true, () => false))
// 真实运行里数据源一张目录都没有,挑表和 SQL 检查都用不上目录:这一行下面提示起草,并给去目录页的入口
const noCatalog = ctxRow.locator('[data-step-next]')
check('没有数据目录的大库:提示先起草目录', await noCatalog.count() === 1
&& (await noCatalog.innerText()).includes('这个数据源还没有数据目录,起草后挑表和 SQL 检查会更准'),
await noCatalog.count() ? await noCatalog.innerText() : '没有这一句')
check('……入口直达这个数据源的目录页', await ctxRow.locator('a[data-fix="catalog"]').getAttribute('href').catch(() => null)
=== '/data/catalog/src-shop')
check('没有运行时报错', errors.length === 0, errors[0] ?? '')
await ctx.close()
})
+22
View File
@@ -682,6 +682,28 @@ await section('Copilot:这一轮参考了哪些表(context 操作)', async
check('挑表失败:原因和库的规模放在展开区', !!fb?.detail?.includes('原因:挑选数据表超过 20 秒未完成')
&& fb.detail.includes('「scenic」共 51 张表'), fb?.detail)
check('挑表失败也说等了多久', fb?.ms === 20004, String(fb?.ms))
// 真实运行里数据源一张目录都没有,挑表、SQL 检查都用不上目录,用户也不知道该先去起草
check('没有数据目录的大库:下一步提示起草目录,入口直达那个源的目录页',
fb?.next === '这个数据源还没有数据目录,起草后挑表和 SQL 检查会更准' && fb?.fix === 'catalog'
&& fb?.fixTo === '/data/catalog/src-scenic', JSON.stringify({ next: fb?.next, fix: fb?.fix, fixTo: fb?.fixTo }))
check('有目录的大库、没有目录的小库:不提示', !row?.next && !row?.fix && !row?.fixTo, JSON.stringify({ next: row?.next }))
const bare = mod.copilotContext({ op: 'context', sources: [
{ source: 'a', source_id: 'id-a', tables: ['x'], selected_by: 'model', total: 60, catalog_tables: 0 },
{ source: 'b', source_id: 'id-b', tables: ['y'], selected_by: 'all', total: 3, catalog_tables: 0 },
{ source: 'c', source_id: 'id c', tables: [], selected_by: 'fallback', total: 90, catalog_tables: 0, reason: 'r' }] })
check('几个数据源:点名没有目录的大库,入口去第一个', bare?.next === '「a」「c」还没有数据目录,起草后挑表和 SQL 检查会更准'
&& bare?.fixTo === '/data/catalog/id-a', JSON.stringify({ next: bare?.next, fixTo: bare?.fixTo }))
const partly = mod.copilotContext({ op: 'context', sources: [
{ source: 'a', source_id: 'id-a', tables: ['x'], selected_by: 'model', total: 60, catalog_tables: 3 }] })
check('起草过一部分目录:不再提示', !partly?.next, partly?.next)
const old = mod.copilotContext({ op: 'context', sources: [{ source: 'a', tables: ['x'], selected_by: 'model', total: 60 }] })
check('老服务端不给目录表数:不猜,不提示', !old?.next && !old?.fixTo, old?.next)
const noId = mod.copilotContext({ op: 'context', sources: [
{ source: 'a', tables: [], selected_by: 'fallback', total: 60, catalog_tables: 0 }] })
check('没给数据源 id:照样提示,只是不给入口', !!noId?.next && !noId?.fixTo, JSON.stringify(noId))
const step = mod.decodeCopilot([{ op: 'context', sources: [
{ source: 'a', tables: [], selected_by: 'fallback', total: 60, catalog_tables: 0 }] }]).find((s) => s.code === 'copilot_context')
check('没有入口时不带 fix:不画一个点了没处去的按钮', !!step?.next && !step?.fix, JSON.stringify(step))
const seeded = mod.copilotContext({ op: 'context', sources: [
{ source: 'scenic', tables: ['stores'], selected_by: 'fallback', total: 51, reason: '模型未挑出任何表' }] })
+12
View File
@@ -774,12 +774,24 @@ await section('参考了哪些表:画布右栏和问数据页(context 操作
&& 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('有数据目录的大库:不提示起草目录', await row.locator('[data-step-next]').count() === 0
&& await row.locator('[data-fix="catalog"]').count() === 0)
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('未能按需求挑选,已提供全部表名'))
// 真实运行里数据源一张目录都没有:这一行下面常显下一步,入口去那个源的目录页
const hint = fb.locator('[data-step-next]')
check('没有数据目录的大库:常显「还没有数据目录」,不收进展开区', await hint.count() === 1
&& (await hint.innerText()).includes('这个数据源还没有数据目录,起草后挑表和 SQL 检查会更准'),
await hint.count() ? await hint.innerText() : '没有这一句')
const go = fb.locator('a[data-fix="catalog"]')
check('……附去数据目录页的入口', await go.count() === 1 && await go.getAttribute('href') === '/data/catalog/src-scenic'
&& (await go.innerText()).includes('去数据目录起草'), await go.count() ? await go.getAttribute('href') : '没有入口')
const narrow = await f.page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)
check('……不撑破 380px 窄栏', narrow <= 0, `${narrow}px`)
await fb.locator('button').first().click()
await f.page.waitForTimeout(150)
check('挑表失败:展开看到原因', (await fb.innerText()).includes('原因:挑选数据表超过 20 秒未完成'))