@@ -1740,6 +1740,40 @@ describe("gateway session utils", () => {
17401740 expect ( row . execCwd ) . toBe ( "/Users/peter/Projects/openclaw" ) ;
17411741 } ) ;
17421742
1743+ test ( "buildGatewaySessionRow projects the session root only for an explicit permission mode" , ( ) => {
1744+ const cfg = { agents : { list : [ { id : "main" , default : true } ] } } as OpenClawConfig ;
1745+ const ordinaryEntry : SessionEntry = {
1746+ sessionId : "ordinary" ,
1747+ sessionRoot : "/workspace/private" ,
1748+ updatedAt : 1 ,
1749+ } ;
1750+ const ordinaryRow = buildGatewaySessionRow ( {
1751+ cfg,
1752+ storePath : "" ,
1753+ store : { "agent:main:ordinary" : ordinaryEntry } ,
1754+ key : "agent:main:ordinary" ,
1755+ entry : ordinaryEntry ,
1756+ } ) ;
1757+ expect ( ordinaryRow ) . not . toHaveProperty ( "sessionRoot" ) ;
1758+
1759+ const permissionEntry : SessionEntry = {
1760+ ...ordinaryEntry ,
1761+ permissionMode : "workspace" ,
1762+ sessionId : "permission" ,
1763+ } ;
1764+ const permissionRow = buildGatewaySessionRow ( {
1765+ cfg,
1766+ storePath : "" ,
1767+ store : { "agent:main:permission" : permissionEntry } ,
1768+ key : "agent:main:permission" ,
1769+ entry : permissionEntry ,
1770+ } ) ;
1771+ expect ( permissionRow ) . toMatchObject ( {
1772+ permissionMode : "workspace" ,
1773+ sessionRoot : "/workspace/private" ,
1774+ } ) ;
1775+ } ) ;
1776+
17431777 test ( "buildGatewaySessionRow prefers entry.label over origin.label for direct sessions" , ( ) => {
17441778 const cfg = { agents : { list : [ { id : "main" , default : true } ] } } as OpenClawConfig ;
17451779 const entry : SessionEntry = {
0 commit comments