Accessing workspace data

I’m working on a plugin to expose workspaces in the UI as tabs, and also generally make workspaces easier to manage. The way I’m using workspaces is really analogous to how I use tabs in other apps, so I thought I’d expose them in the UI in the same way. I have the basic functionality working (in kind of a hacky way, by manually reading the workspaces.json file), but there a few things that I can’t find a way to do.

  • As far as I can tell, the only way to save a workspace is to open the “Manage Workspaces” command, then retype the exact name of the workspace again to resave it. This is kinda error prone and kinda breaks the flow of moving from workspace to workspace. So, I’m hoping there’s an easier way to save the current state of the workspace. I tried but nothing happened. Is there something available that I’m overlooking?
  • Is there a way to know which workspace is currently active?
  • I’d also like to be able to keep the plugin UI up to date with any new workspaces that have been created. Is there a way to listen for workspaces being created?

I’m kinda new to plugin development, so I’m not sure if I’m overlooking something obvious or anything. Thanks in advance for any help that people can provide!

Of course, immediately after posting, I stumbled on some of what I need. There’s an active field in workspaces.json :man_facepalming:. I didn’t notice it, since it’s at the bottom of the file. I think this also gives me a way to persist changes by writing to workspaces.json manually. But I wonder, should I be mucking about in the filesystem for this data, or is there a more “approved” way to get/set it from the Obsidian API? This feels very brittle.

Were you able to resolve the questions about the workspace data? I am looking for a plug-in that will list the workspaces in a UI window so I can keep the list as I work thru different projects.