@@ -1622,7 +1622,7 @@ describe('transformBlockTool multi-instance unique IDs', () => {
16221622 expect ( result ?. id ) . toBe ( 'table_query_rows_tbl_abc' )
16231623 } )
16241624
1625- it ( 'resolves the canonical table id before enriching the LLM tool schema' , async ( ) => {
1625+ it ( 'resolves the active table selector before enriching the LLM tool schema' , async ( ) => {
16261626 const enrichTool = vi . fn (
16271627 async (
16281628 tableId : string ,
@@ -1646,7 +1646,7 @@ describe('transformBlockTool multi-instance unique IDs', () => {
16461646 {
16471647 type : 'table' ,
16481648 operation : 'query_rows' ,
1649- params : { tableSelector : 'tbl_abc ' } ,
1649+ params : { tableId : 'tbl_stale' , tableSelector : 'tbl_active ' } ,
16501650 } ,
16511651 {
16521652 selectedOperation : 'query_rows' ,
@@ -1672,7 +1672,7 @@ describe('transformBlockTool multi-instance unique IDs', () => {
16721672 )
16731673
16741674 expect ( enrichTool ) . toHaveBeenCalledWith (
1675- 'tbl_abc ' ,
1675+ 'tbl_active ' ,
16761676 expect . objectContaining ( {
16771677 properties : expect . objectContaining ( { filter : expect . any ( Object ) } ) ,
16781678 } ) ,
@@ -1683,15 +1683,16 @@ describe('transformBlockTool multi-instance unique IDs', () => {
16831683 }
16841684 )
16851685 expect ( result ) . toMatchObject ( {
1686- id : 'table_query_rows_tbl_abc ' ,
1687- description : 'Query rows from tbl_abc ' ,
1688- params : { tableSelector : 'tbl_abc ' } ,
1686+ id : 'table_query_rows_tbl_active ' ,
1687+ description : 'Query rows from tbl_active ' ,
1688+ params : { tableId : 'tbl_stale' , tableSelector : 'tbl_active ' } ,
16891689 parameters : {
16901690 properties : {
16911691 customer_name : { type : 'string' } ,
16921692 } ,
16931693 } ,
16941694 } )
1695+ expect ( result ?. paramsTransform ?.( result . params ) ) . toEqual ( { tableId : 'tbl_active' } )
16951696 } )
16961697
16971698 it ( 'appends the table id resolved from the advanced manual input' , async ( ) => {
@@ -1715,6 +1716,16 @@ describe('transformBlockTool multi-instance unique IDs', () => {
17151716 expect ( result ?. id ) . toBe ( 'table_query_rows_tbl_direct' )
17161717 } )
17171718
1719+ it ( 'preserves the canonical table id when advanced mode is active' , async ( ) => {
1720+ const result = await transformTable (
1721+ { tableId : 'tbl_advanced' , tableSelector : 'tbl_basic' } ,
1722+ { '0:tableId' : 'advanced' } ,
1723+ 0
1724+ )
1725+ expect ( result ?. id ) . toBe ( 'table_query_rows_tbl_advanced' )
1726+ expect ( result ?. paramsTransform ?.( result . params ) ) . toEqual ( { tableId : 'tbl_advanced' } )
1727+ } )
1728+
17181729 it ( 'falls back to the base tool id when no table is selected' , async ( ) => {
17191730 const result = await transformTable ( { } )
17201731 expect ( result ?. id ) . toBe ( 'table_query_rows' )
0 commit comments