feat: add ASSET_SIDEBAR location constants [Ext-6786]#2336
feat: add ASSET_SIDEBAR location constants [Ext-6786]#2336Tyler (tylerwashington888) wants to merge 1 commit intomainfrom
Conversation
WalkthroughAdds a new location key, LOCATION_ASSET_SIDEBAR ('asset-sidebar'), to the Locations map and its corresponding Typescript interface, extending recognized location identifiers without altering existing logic. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Comment |
- Add LOCATION_ASSET_SIDEBAR to locations.ts - Update Locations interface in api.types.ts - Part of EXT-6786: Asset Sidebar App Framework Location
7615f8c to
978ba90
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
lib/types/api.types.ts (1)
389-389: Consider asset-scoped SDK typing (follow-up).If apps will run in Asset Sidebar soon, consider adding asset-scoped IDs (e.g.,
asset) and a context-aware SDK (newAssetSidebarAppSDKor wideningSidebarAppSDK) so types match runtime.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
lib/locations.ts(1 hunks)lib/types/api.types.ts(1 hunks)
🔇 Additional comments (1)
lib/types/api.types.ts (1)
389-389: Type entry added — verified.ConnectMessage.location is typed as Location[keyof Location] (lib/types/api.types.ts) so 'asset-sidebar' is included.
'asset-sidebar' only appears in lib/locations.ts and lib/types/api.types.ts — no other consumers found.
| LOCATION_ENTRY_FIELD: 'entry-field', | ||
| LOCATION_ENTRY_FIELD_SIDEBAR: 'entry-field-sidebar', | ||
| LOCATION_ENTRY_SIDEBAR: 'entry-sidebar', | ||
| LOCATION_ASSET_SIDEBAR: 'asset-sidebar', |
There was a problem hiding this comment.
🧩 Analysis chain
New location key added — looks good.
Addition aligns with existing naming and mapping conventions.
Run to confirm type availability and barrel re-exports resolve correctly, and that Location[keyof Location] includes 'asset-sidebar':
🏁 Script executed:
#!/bin/bash
# Definitions for Location/Locations
rg -nP -C2 'export\s+(?:type|interface)\s+Location\b' lib
rg -nP -C2 'export\s+(?:type|interface)\s+Locations\b' lib
# Ensure the literal is present across types and constants
rg -n -C2 "asset-sidebar" libLength of output: 941
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "----- search for singular 'Location' type/interface declarations -----"
rg -nP -C2 '(^|\s)export\s+(?:type|interface)\s+Location\b' || true
rg -nP -C2 '\btype\s+Location\b' || true
echo
echo "----- search for 'Locations' declarations/uses -----"
rg -nP -n -C2 '\bLocations\b' || true
echo
echo "----- search for 'keyof Location' / 'Location[keyof' usages -----"
rg -nP -n -C2 'keyof\s+Location' || true
rg -nP -n -C2 'Location\s*\[\s*keyof' || true
echo
echo "----- show lib/locations.ts -----"
if [ -f lib/locations.ts ]; then
sed -n '1,240p' lib/locations.ts
else
echo "lib/locations.ts not found"
fi
echo
echo "----- show lib/types/api.types.ts (around Locations) -----"
if [ -f lib/types/api.types.ts ]; then
sed -n '360,420p' lib/types/api.types.ts || true
else
echo "lib/types/api.types.ts not found"
fi
echo
echo "----- search for barrel re-exports referencing locations/types -----"
rg -nP -C2 "export .* from .*locations" || true
rg -nP -C2 "export .* from .*types" || true
rg -nP -C2 "export \* from .*locations" || true
rg -nP -C2 "export \* from .*types" || true
echo
echo "----- show lib/index.ts and lib/types/index.ts if present -----"
[ -f lib/index.ts ] && sed -n '1,240p' lib/index.ts || echo "lib/index.ts not found"
[ -f lib/types/index.ts ] && sed -n '1,240p' lib/types/index.ts || echo "lib/types/index.ts not found"Length of output: 8244
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "----- all 'Location' word occurrences -----"
rg -nP --hidden '\bLocation\b' lib || true
echo
echo "----- explicit 'type Location' / 'interface Location' matches -----"
rg -nP '\b(type|interface)\s+Location\b' lib || true
rg -nP '\btype\s+Location\s*=' lib || true
echo
echo "----- show start of lib/types/api.types.ts (1-480) -----"
sed -n '1,480p' lib/types/api.types.ts || true
echo
echo "----- show lib/types/index.ts (1-240) -----"
sed -n '1,240p' lib/types/index.ts || trueLength of output: 16720
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "----- show lib/types/utils.ts (full) -----"
if [ -f lib/types/utils.ts ]; then
sed -n '1,240p' lib/types/utils.ts || true
else
echo "lib/types/utils.ts not found"
fi
echo
echo "----- search for 'type Location' or 'export type Location' -----"
rg -nP '\b(export\s+)?type\s+Location\b' || true
echo
echo "----- search for 'Location =' patterns -----"
rg -nP 'Location\s*=' || trueLength of output: 2749
Fix ConnectMessage type: Location is undefined — use Locations
Locations interface (lib/types/api.types.ts:385) and lib/locations.ts include 'asset-sidebar', but ConnectMessage uses location: Location[keyof Location] (lib/types/api.types.ts:399); there is no Location type in the repo so this resolves to the global DOM Location and does not include 'asset-sidebar'. Action: change to location: Locations[keyof Locations] or add export type Location = Locations in the types so the indexed type includes the new literal.
🤖 Prompt for AI Agents
In lib/locations.ts around line 7, the export LOCATION_ASSET_SIDEBAR adds
'asset-sidebar' to the Locations map but ConnectMessage in
lib/types/api.types.ts uses a non-existent Location type causing TypeScript to
resolve to the global DOM Location and miss this literal; fix by updating the
ConnectMessage type to reference the correct indexed type (location:
Locations[keyof Locations]) or add an export alias type (export type Location =
Locations) in the types file so the indexed type includes 'asset-sidebar' and
other literals.
Why UI Extensions SDK Needs These Changes
Apps need to know where they're running. The UI Extensions SDK provides this through sdk.location.is():
Without the location constant, this check would fail because the SDK doesn't recognize 'asset-sidebar' as a valid location.
The Locations interface provides TypeScript type safety:
The UI Extensions SDK is the central source of truth for all location constants. Other parts of the system (like the widget renderer) import and use these constants:
When an app is loaded in the asset-sidebar location, the UI Extensions SDK needs to:
Summary by CodeRabbit