As you've found, each application behaves differently with respect to lifecycle of the extension. Here we have a range of behaviors - on one end of the spectrum we have Photoshop which greedily unloads extensions whenever possible, and at the other end we have Illustrator which doesn’t unload an extension when it is closed through the UI.
For #1, you have a couple of choices.
- Maintain the state of your extension somewhere that will persist between loading/unloading (e.g. on disk). When your extension is loaded, check this persistent state to see which UI you should present to the user.
- Use CSXSInterface.evalScript(“PhotoshopPersistent”) which will prevent Photoshop from unloading the panel when it is collapsed.
For #2, you theoretically shouldn’t have to login again, since your panel has not be unloaded. As far as I know, Illustrator does not expose a similar mechanism for forcing an unload, although the Illustrator forum may be a better place to get a more definitive answer.