🐛 fix(sidebar): 修复视图定位慢加载误报

- 兼容 table-prefixed key 的视图兜底定位

- 区分对象树仍在加载与真实未找到状态

- 补充 sidebarLocate 与 Sidebar 定位回归测试
This commit is contained in:
Syngnat
2026-06-10 01:13:29 +08:00
parent 01d8fe44ce
commit cb90a4ad01
4 changed files with 56 additions and 4 deletions

View File

@@ -660,6 +660,47 @@ describe('sidebarLocate', () => {
]);
});
it('falls back to a visual table-like node with a table-prefixed key for a view request', () => {
const target = resolveSidebarLocateTarget({
tabId: 'stale-view-tab-id',
connectionId: 'conn-1',
dbName: 'SYSDBA',
tableName: 'V_ACCOUNT',
objectGroup: 'views',
}, { groupBySchema: false });
const tree = [
{
key: 'conn-1',
children: [
{
key: 'conn-1-SYSDBA',
dataRef: { id: 'conn-1', dbName: 'SYSDBA' },
children: [
{
key: 'conn-1-SYSDBA-tables',
children: [
{
key: 'conn-1-SYSDBA-table-V_ACCOUNT',
type: 'table',
dataRef: {},
},
],
},
],
},
],
},
];
expect(findSidebarNodePathForLocate(tree, target)).toEqual([
'conn-1',
'conn-1-SYSDBA',
'conn-1-SYSDBA-tables',
'conn-1-SYSDBA-table-V_ACCOUNT',
]);
});
it('finds a view node by title when the tree node is missing object metadata', () => {
const target = resolveSidebarLocateTarget({
tabId: 'stale-view-tab-id',

View File

@@ -402,7 +402,7 @@ const getVisualNodeObjectName = (
? [`${target.databaseKey}-trigger-`]
: target.objectGroup === 'routines'
? [`${target.databaseKey}-routine-`]
: [`${target.databaseKey}-`];
: [`${target.databaseKey}-table-`, `${target.databaseKey}-`];
const matchedPrefix = keyPrefixes.find((prefix) => nodeKey.startsWith(prefix));
return matchedPrefix ? nodeKey.slice(matchedPrefix.length) : '';