Although I didn't find any official doc, state.json is used for saving the Windows Terminal session state when Open windows from previous session setting is enabled ("firstWindowPreference": "persistedWindowLayout" in settings.json as described here.
I'm fiddling with state.json a lot because I'm constantly customizing my startup tabs, directories etc. and it seems it works with the concept of actions. It seems that Windows Terminal replays actions specified in state.json upon WT startup while possible actions might be "open tab in this directory with such title", "rename the tab to 'something'" etc.
I tried to search for some state.json spec briefly and I was unsuccessful, but it seems the list of available actions is specified here in WT github
One can deduce a lot from their names. For example, the action switchToTab allows setting the default active tab upon WT start.
Here is a snippet from my state.json, that opens two tabs and sets the second one to active:
{
"action" : "newTab",
"commandline" : "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"",
"profile" : "PowerShell",
"startingDirectory" : "P:\\git-cz-moneta-wps\\wps\\devops\\openapi-codegen\\output",
"suppressApplicationTitle" : false,
"tabTitle" : "openapi-codegen/output"
},
{
"action" : "newTab",
"commandline" : "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"",
"profile" : "PowerShell",
"startingDirectory" : "s:\\",
"suppressApplicationTitle" : false,
"tabTitle" : "scripts"
},
{
"action" : "switchToTab",
"index" : 1
}