Thanks to some coworkers and David Wilson’s Emacs from Scratch playlist, I’ve been getting back into Emacs. The community is more vibrant than the last time I looked, and LSP brings modern completion and inline type checking.
TL;DR: Explanation of why the escape sequence for 256 color and 24 bit color modes are weird and can vary. \E[38:5:_n_m is technically the correct form for 256 color, but \E[38;5;_n_m is the form terminals more widely support.
If you're using emacs, stick to the GUI unless you have good reasons not to. The GUI is more or less a smart terminal. You're missing out on a lot of features if you opt for the terminal.