w command shows incorrect idle time and missing logins

Some sessions are completely missing from "w" output, as here:

$ tty
/dev/pts/2
$ w
 06:56:54 up 25 min,  1 user,  load average: 0.35, 0.38, 0.34
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
xxx      tty2      06:31   25:51   0.21s  0.21s /usr/bin/startplasma-wayland
$ 

Or (via an ssh session here) idle time is wrong and TTY is missing (idle should be zero and WHAT should be w):

$ w
 06:58:49 up 2 days, 19:08,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
xxx                06:58    3:31   0.00s  0.03s sshd: xxx [priv]

I am running Fedora 40, and this seems to have started in 4.0.4, as 4.0.3 in Fedora 39 did not have this problem.