I cannot reproduce your situation (Ventura 13.4.1 (c) ). I Launch macOS Terminal. I create several new tabs. I hide macOS Terminal. I switch to other apps. I unhide macOS Terminal. Command-1, Command-2, etc... all works. I even tried creating a 2nd window with several tabs, and repeated the hide, play around, unhide, Command-1, Command-2, ... test in both windows, and it still worked as expected.
- The shell will not affect the GUI parts of macOS Terminal.
- The TERM=xterm-256color vs TERM=vt102 will not affect the GUI parts of macOS Terminal. All that this setting does is tell the programs you run how to move the cursor around and how many colors they are allowed to use. macOS Terminal always supports all the colors it is going to support, and if you select a TERM setting with less colors, you can still send the escape sequences to generate more colors. If you specify a less capable terminal type, such as vt100, you can still send macOS Terminal escape sequences for more advanced terminal types. And generally speaking, xterm-256color is the best choice so the programs you run will know they have a more advanced terminal emulator to work with.
Stupid Question? Do you use a 3rd party keyboard?
I use either my MacBook Pro keyboard, or a Apple USB extended keyboard, with and Apple Magic Trackpad on the side of it.
If you are using a 3rd party keyboard, that may be something to factor into the problem.
At work, I live in a terminal emulator. I happen to use iTerm2 (https://iterm2.com; free), but mostly because when it was Mac OS X 10.3, Terminal did not support tabbed windows, but iTerm did, plus iTerm had a few other features I found useful. Since the early 2000's Terminal has improved, and now includes many of the reasons I started using iTerm (and eventually iTerm2). But there are still a few iTerm2 features I am hooked on, so I stay with iTerm2.
iTerm2 also has the Command-1, Command-2, etc... tab switching feature as well.
I AM NOT suggesting you switch to iTerm2, I'm just pointing out there are alternatives.
I am going to suggest you experiment with iTerm2 to see if Command-1, Command-2, ... works correctly on your system. Because IF IT DOES NOT work correctly, then this would imply there is something interfering with both terminal emulators.
As I said, I live in terminal emulators, but I DO NOT use Command-1, Command-2, etc... I use a Magic Trackpad, and BetterTouchTool (https://folivora.ai; paid app) and I have mapped a 3-finger left and right swipe to move to the previous or next tab. I have also used BetterTouchTool to map Control-Page-Up and Control-Page-Down to move to the previous or next tab (I have an extended keyboard with Page-Up and Page-Down keys). This works for me. If I need to move to a specify tab, I use my mouse. I never got into the habit of Command-1, Command-2, ....
Would you be interested in posting the output from an EtreCheck run?
https://EtreCheck.com
Just the free version. You do not have to pay for any of the extras.
EtreCheck should show if you have any 3rd party additions that maybe you forgot about, or were unaware of.