You just need to define separate landing pages with actions to run in the manifest:
<ExtensionPoint xsi:type="MessageReadCommandSurface">
<Action xsi:type="ExecuteFunction">
<FunctionName>FunctionSpecificToReadView</FunctionName>
</Action>
</ExtensionPoint>
<ExtensionPoint xsi:type="MessageComposeCommandSurface">
<Action xsi:type="ExecuteFunction">
<FunctionName>FunctionSpecificToComposeView</FunctionName>
</Action>
</ExtensionPoint>
If you don't want to create two separate landing pages for read and compose modes you may check for the displayReplyForm
API, this is available in the read mode. If this is not defined then you are in compose mode:
if (Office.context.mailbox.item.displayReplyForm != undefined) {
// read mode
} else {
// compose mode
}