Redirect "current file has changed" events (on_new, on_load, on_activated - make sure to use the async ones) to a function to see if window.project_file_name() has changed. You should remember the project filename separately for each window.id().
You can also check window.folders(), but you might need to do this on a timer. Checking asynchronously every 50-250ms shouldn't hurt performance and will still seem pretty responsive. You should also see if adding a folder triggers a settings on_change listener anywhere.