fix: load hub resource type names where drawers title a type

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-09-14 13:32:26 +02:00
co-authored by Claude Opus 5
parent ad6c3811d1
commit f99047c698
4 changed files with 13 additions and 3 deletions
@@ -45,6 +45,7 @@
alphabetical,
byPopularity,
hubResourceTypePicks,
loadHubResourceTypeDisplayNames,
localResourceTypeCounts,
recordHubResourceTypePick
} from './pickerPopularity'
@@ -340,6 +341,9 @@
if (!rt) {
loadResourceTypes()
loadPopularity()
} else if (effectiveWorkspace) {
// Opened straight on a type, so its title reads hub names nothing here has loaded yet.
void loadHubResourceTypeDisplayNames(effectiveWorkspace)
}
step = 1 //express && !manual ? 3 : 1
// The list is keyboard-driven from the search field, so it takes focus on open.
@@ -10,6 +10,7 @@
import Select from './select/Select.svelte'
import IconedResourceType from './IconedResourceType.svelte'
import { addResourceTitle } from './resourceTypeDisplay'
import { loadHubResourceTypeDisplayNames } from './pickerPopularity'
interface Props {
value: string | undefined
@@ -218,6 +219,7 @@
on:click={() => {
refreshCount += 1
open = true
if (ws) void loadHubResourceTypeDisplayNames(ws)
drawer?.openDrawer?.()
}}
startIcon={{ icon: Plus }}
@@ -18,6 +18,7 @@
import ResourceVersionHistory from './ResourceVersionHistory.svelte'
import IconedResourceType from './IconedResourceType.svelte'
import { addResourceTitle } from './resourceTypeDisplay'
import { loadHubResourceTypeDisplayNames } from './pickerPopularity'
let {
workspace = undefined,
@@ -106,6 +107,8 @@
// rather than left where the last one put it: a new resource is a typed form, whoever was
// looking at JSON before.
viewJsonSchema = false
// The title names the type, and nothing else on the page may have loaded the hub's names.
void loadHubResourceTypeDisplayNames(effectiveWorkspace)
drawer?.openDrawer?.()
}
@@ -193,9 +193,10 @@ const hubIntegrationNames = new SvelteMap<string, string>()
type HubNamed = { name: string; display_name?: string | null }
/**
* Takes a complete hub listing, so an entry without a name drops any name kept for it. A hub
* predating display names sends none at all, and switching to one must revert to the inferred
* labels rather than keep the previous hub's.
* Updates only the entries the listing carries: one without a name drops any name kept for it,
* which is how switching to a hub predating display names reverts to inferred labels. Entries
* absent from the listing are left alone on purpose, since callers pass `kind`-filtered
* listings, and clearing those would wipe names another filter loaded.
*/
function recordHubNames(names: SvelteMap<string, string>, entries: HubNamed[]): void {
for (const entry of entries) {