@@ -25,8 +25,8 @@ import {
2525const suite = createSessionManagementE2eSuite ( ) ;
2626
2727suite . define ( ( ) => {
28- it ( "shows an unsent- draft pencil after switching sessions and removes it after clearing " , async ( ) => {
29- const firstKey = "agent:main:draft-first " ;
28+ it ( "keeps the browser-local draft pencil visible on active Home beside activity " , async ( ) => {
29+ const mainKey = "agent:main:main " ;
3030 const secondKey = "agent:main:draft-second" ;
3131 const context = await suite . browser . newContext ( {
3232 colorScheme : "dark" ,
@@ -38,39 +38,54 @@ suite.define(() => {
3838 await installMockGateway ( page , {
3939 methodResponses : {
4040 "sessions.list" : sessionsListResponse ( [
41- sessionRow ( firstKey , "Draft first" , 2 ) ,
41+ sessionRow ( mainKey , "Main" , 2 , {
42+ hasActiveRun : true ,
43+ startedAt : 1 ,
44+ status : "running" ,
45+ } ) ,
4246 sessionRow ( secondKey , "Draft second" , 1 ) ,
4347 ] ) ,
4448 } ,
45- sessionKey : firstKey ,
49+ sessionKey : mainKey ,
4650 } ) ;
4751
4852 try {
49- await page . goto ( controlUiSessionUrl ( suite . server . baseUrl , firstKey ) ) ;
50- const firstRow = page . locator ( `[data-session-key=" ${ firstKey } "]` ) ;
53+ await page . goto ( controlUiSessionUrl ( suite . server . baseUrl , mainKey ) ) ;
54+ const homeRow = page . locator ( ".nav-item--home" ) ;
5155 const secondRow = page . locator ( `[data-session-key="${ secondKey } "]` ) ;
5256 const composer = page . locator (
5357 'openclaw-chat-pane[aria-hidden="false"] .agent-chat__composer-combobox > textarea' ,
5458 ) ;
55- await firstRow . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
59+ await homeRow . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
5660 await secondRow . waitFor ( { state : "visible" } ) ;
5761 await composer . waitFor ( { state : "visible" } ) ;
5862 await captureUiProof ( page , "draft-indicator-before.png" ) ;
5963
6064 await composer . fill ( "Keep this unsent" ) ;
65+ const activity = homeRow . getByRole ( "img" , { name : "Active run" } ) ;
66+ const draft = homeRow . getByRole ( "img" , { name : "Unsent draft" } ) ;
67+ await activity . waitFor ( ) ;
68+ await draft . waitFor ( ) ;
69+ const activityBox = await activity . boundingBox ( ) ;
70+ const draftBox = await draft . boundingBox ( ) ;
71+ if ( ! activityBox || ! draftBox ) {
72+ throw new Error ( "expected activity and draft icon bounds" ) ;
73+ }
74+ expect ( draftBox . x ) . toBeGreaterThanOrEqual ( activityBox . x + activityBox . width ) ;
75+ await captureUiProof ( page , "draft-indicator-active.png" ) ;
76+
6177 await secondRow . getByRole ( "link" ) . click ( ) ;
6278 await expect . poll ( ( ) => new URL ( page . url ( ) ) . pathname ) . toBe ( controlUiSessionPath ( secondKey ) ) ;
63- await firstRow . getByRole ( "img" , { name : "Unsent draft" } ) . waitFor ( ) ;
64- await captureUiProof ( page , "draft-indicator-after.png" ) ;
79+ await draft . waitFor ( ) ;
6580
66- await firstRow . getByRole ( "link" ) . click ( ) ;
67- await expect . poll ( ( ) => new URL ( page . url ( ) ) . pathname ) . toBe ( controlUiSessionPath ( firstKey ) ) ;
68- expect ( await firstRow . getByRole ( "img" , { name : "Unsent draft" } ) . count ( ) ) . toBe ( 0 ) ;
81+ await homeRow . click ( ) ;
82+ await expect . poll ( ( ) => new URL ( page . url ( ) ) . pathname ) . toBe ( controlUiSessionPath ( mainKey ) ) ;
83+ await draft . waitFor ( ) ;
6984
7085 await composer . fill ( "" ) ;
7186 await secondRow . getByRole ( "link" ) . click ( ) ;
7287 await expect . poll ( ( ) => new URL ( page . url ( ) ) . pathname ) . toBe ( controlUiSessionPath ( secondKey ) ) ;
73- await expect . poll ( ( ) => firstRow . getByRole ( "img" , { name : "Unsent draft" } ) . count ( ) ) . toBe ( 0 ) ;
88+ await expect . poll ( ( ) => draft . count ( ) ) . toBe ( 0 ) ;
7489 } finally {
7590 await context . close ( ) ;
7691 }
0 commit comments