Skip to content

Conversation

tylerwashington888
Copy link
Contributor

@tylerwashington888 tylerwashington888 commented Sep 23, 2025

Why UI Extensions SDK Needs These Changes

  1. Location Detection for Apps
    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.
// In an app, developers write:
if (sdk.location.is('asset-sidebar')) {
  // Render asset-sidebar specific UI
}
  1. Type Safety
    The Locations interface provides TypeScript type safety:
// This ensures only valid locations can be used
sdk.location.is('asset-sidebar') // ✅ TypeScript knows this is valid
sdk.location.is('invalid-location') // ❌ TypeScript error
  1. SDK API Consistency
    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:

// In experience-packages, they import from ui-extensions-sdk:
import { locations } from '@contentful/ui-extensions-sdk'
// Then use: locations.LOCATION_ASSET_SIDEBAR
  1. App Framework Integration
    When an app is loaded in the asset-sidebar location, the UI Extensions SDK needs to:
  • Recognize the location type
  • Provide the appropriate APIs for that location
  • Handle location-specific behavior

Summary by CodeRabbit

  • New Features
    • Added support for an Asset Sidebar location in the interface, allowing compatible apps or widgets to appear alongside asset details.
    • Users may now access contextual tools directly from the asset sidebar for a smoother workflow and quicker actions without leaving the asset view.

@tylerwashington888 tylerwashington888 requested review from a team as code owners September 23, 2025 21:19
Copy link

coderabbitai bot commented Sep 23, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
Locations mapping update
lib/locations.ts
Added LOCATION_ASSET_SIDEBAR mapped to 'asset-sidebar' in the exported Locations object.
Type interface extension
lib/types/api.types.ts
Added LOCATION_ASSET_SIDEBAR: 'asset-sidebar' to the Locations interface.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit taps keys with a gentle flair,
“asset-sidebar” now hops into our lair.
New nook, new burrow in the code’s green glade,
Types and maps agree—foundations laid.
Thump-thump! I file this change with care.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely summarizes the primary change — adding ASSET_SIDEBAR location constants — and matches the diffs that add LOCATION_ASSET_SIDEBAR in lib/locations.ts and lib/types/api.types.ts, including the issue reference for traceability. It is specific, short, and relevant to the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/asset-sidebar-location-constants

Comment @coderabbitai help to get the list of available commands and usage tips.

- Add LOCATION_ASSET_SIDEBAR to locations.ts
- Update Locations interface in api.types.ts
- Part of EXT-6786: Asset Sidebar App Framework Location
@tylerwashington888 tylerwashington888 force-pushed the feature/asset-sidebar-location-constants branch from 7615f8c to 978ba90 Compare September 23, 2025 21:19
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (new AssetSidebarAppSDK or widening SidebarAppSDK) so types match runtime.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2642730 and 978ba90.

📒 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',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 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" lib

Length 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 || true

Length 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*=' || true

Length 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant