If you switch a couple of themes that provide block template parts you can get into a state where all of the previous ones are listed:

I believe this is happening because the auto-drafts are being created for them, but there is no way to view or delete those in current wp_template_part listing, since the draft category is not shown.
I think that it would be better to avoid displaying these theme template part drafts that were not previously modified.
Why are we creating them in the first place?
Why are we creating them in the first place?
I'm not completely sure since they predate our work on FSE. I'm assuming it's partly to avoid loading from theme files directly, and to give special status to denote that it hasn't been changed compared to the base version, but there might have been other reasons at the time.
I think that it would be better to avoid displaying these theme template part drafts that were not previously modified.
In other words: all of them. 😄
Using auto-draft as default status of templates and parts converted from files introduces a bunch of complications caused by the fact that auto-draft is a very special status that, supposedly, should be only handled automatically by the editor.
In #26394 I'm proposing a custom status for wp_template that are converted from files and not modified yet, which ideally would be propagated to wp_template_part as well.
About the issue at hand.
The conversion from file happens when several conditions are met:
wp_template_part (it has the requested slug, the current theme in meta, and is status auto-draft).wp_template_part, it compare its content with the file content, and if there are changes it updates the former.wp_template_part, the conversion creates one (this typically happens when activating a new theme). Since in the Site Editor sidebar we only see the slug, we don't have a way to tell "duplicates" apart.Some ways to alleviate this confusion could be:
theme meta in the Site Editor sidebar and in the wp_template_part wp-admin list.auto-draft template parts in the wp_template_part wp-admin list.auto-draft status with a custom one to clearly indicate that a template part is an untouched conversion from file (see #26394).@Copons, could you point me to any document or code that would help me understand the flow for managing wp_template_parts when activating themes?
@gziolo AFAIK there is no flow specifically for theme activation.
Templates and template parts provided as files by the theme are converted into wp_template and wp_template_part posts (if needed) during REST requests on those post types, or when filtering the block_editor_settings.
In other words, the most reliable way to "trigger" the conversion is to open the Site Editor.
Here you can check the rest_wp_template_part_query filter:
https://github.com/WordPress/gutenberg/blob/eaf00bd30636d58c6c81884028b2d4a775954487/lib/template-parts.php#L164-L260
Here the block_editor_settings filter:
https://github.com/WordPress/gutenberg/blob/eaf00bd30636d58c6c81884028b2d4a775954487/lib/template-loader.php#L395-L424
And here is the function that performs the conversion:
https://github.com/WordPress/gutenberg/blob/eaf00bd30636d58c6c81884028b2d4a775954487/lib/template-loader.php#L122-L197
Thank you @Copons for all the pointers, much appreciated 💯
I'm able to reproduce the same issue. It looks like it displays template parts from all previously activated themes:

I activated 3 themes that support FSE and contain template parts.
For full context, I customized only one of them:

_Aside:_ It's a bit unclear for me why template parts used by the current theme aren't listed in the Template Parts section as they technically exist for the current theme, even if it's only a virtual item sourced from the template provided by the theme.
Aside: It's a bit unclear for me why template parts used by the current theme aren't listed in the Template Parts section as they technically exist for the current theme, even if it's only a virtual item sourced from the template provided by the theme.
This is likely because unpublished template parts have the auto-draft status. This post status is excluded from the Post List view.
Saved but unpublished template parts should be drafts instead.
Yes, can confirm it's because auto-draft items are automatically excluded from most (all?) queries.
In #26636 I've modified the wp_template (not template _parts_, but the logic is similar) admin list query to also include auto-draft items.
Major reason: it was becoming extremely hard — at least for me — to work with templates without having a unambiguous source of truth, and a simple way to clear them when doing new activations tests.
_I don't have a strong opinion about keeping auto-draft in the admin list when the Site Editor is stable, or hide them again to be consistent with all the other lists.
Or if we even intend to keep the hide the templates/parts lists as well, and only rely on the Site Editor.
Either way, those are long term discussions that aren't super relevant at the moment._