[SCAL-327613] Add Spotter routes to fullHeight height-reset allowlist - #652
[SCAL-327613] Add Spotter routes to fullHeight height-reset allowlist#652shikharbsar wants to merge 1 commit into
Conversation
Spotter (conv-assist) routes were missing from the RouteChange allowlist that skips the fullHeight iframe height reset, causing the embed to collapse to defaultHeight when navigating into or within Spotter. - Add /insights/conv-assist and /embed/insights/conv-assist to liveboardRelatedRoutes in app.ts and liveboard.ts - Add pinning tests for the bare landing route and the conversation-id URL variant
There was a problem hiding this comment.
Code Review
This pull request adds Spotter (conv-assist) routes to the liveboardRelatedRoutes array in both AppEmbed and LiveboardEmbed to prevent resetting the iframe height during navigation, along with corresponding unit tests. The review feedback highlights a potential partial prefix matching bug due to the lack of trailing slashes on the new routes, and suggests extracting the duplicated route array and matching logic into a shared constants file.
| '/insights/conv-assist', | ||
| '/embed/insights/conv-assist', |
There was a problem hiding this comment.
1. Potential Partial Prefix Match Bug
Because '/insights/conv-assist' and '/embed/insights/conv-assist' do not end with a trailing slash (unlike the other routes in the list), currentPath.startsWith(path) will match any path that has this prefix, such as /insights/conv-assist-settings or /insights/conv-assist-helper if they exist.
Recommendation:
To prevent accidental partial matches and normalize the route matching logic, consider removing trailing slashes from all routes in liveboardRelatedRoutes and updating the matching condition to check for either an exact match or a sub-path match:
if (
liveboardRelatedRoutes.some(
(path) =>
data.data.currentPath === path ||
data.data.currentPath.startsWith(path + '/'),
)
)2. Code Duplication
The liveboardRelatedRoutes array and the setIframeHeightForNonEmbedLiveboard logic are duplicated across AppEmbed (src/embed/app.ts) and LiveboardEmbed (src/embed/liveboard.ts).
Recommendation:
Consider extracting liveboardRelatedRoutes to a shared constants file (e.g., src/config.ts or a new constants module) and importing it in both files. This prevents duplication, improves maintainability, and ensures the routes do not get out of sync in future updates.
| '/insights/conv-assist', | ||
| '/embed/insights/conv-assist', |
There was a problem hiding this comment.
1. Potential Partial Prefix Match Bug
Because '/insights/conv-assist' and '/embed/insights/conv-assist' do not end with a trailing slash (unlike the other routes in the list), currentPath.startsWith(path) will match any path that has this prefix, such as /insights/conv-assist-settings or /insights/conv-assist-helper if they exist.
Recommendation:
To prevent accidental partial matches and normalize the route matching logic, consider removing trailing slashes from all routes in liveboardRelatedRoutes and updating the matching condition to check for either an exact match or a sub-path match:
if (
liveboardRelatedRoutes.some(
(path) =>
data.data.currentPath === path ||
data.data.currentPath.startsWith(path + '/'),
)
)2. Code Duplication
The liveboardRelatedRoutes array and the setIframeHeightForNonEmbedLiveboard logic are duplicated across AppEmbed (src/embed/app.ts) and LiveboardEmbed (src/embed/liveboard.ts).
Recommendation:
Consider extracting liveboardRelatedRoutes to a shared constants file (e.g., src/config.ts or a new constants module) and importing it in both files. This prevents duplication, improves maintainability, and ensures the routes do not get out of sync in future updates.
commit: |
Spotter (conv-assist) routes were missing from the RouteChange allowlist that skips the fullHeight iframe height reset, causing the embed to collapse to defaultHeight when navigating into or within Spotter.