diff --git a/.changeset/fix-banner-carousel.md b/.changeset/fix-banner-carousel.md new file mode 100644 index 00000000..1ddc9a1f --- /dev/null +++ b/.changeset/fix-banner-carousel.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Fix banner carousel styling and dismiss functionality diff --git a/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx b/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx index fe6e9cc7..6ab9e329 100644 --- a/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx +++ b/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx @@ -53,6 +53,25 @@ export const WelcomeSection: React.FC = ({ hideAnnouncement() }, [hideAnnouncement]) + /** + * Check if a banner has been dismissed based on its version + */ + const isBannerDismissed = useCallback( + (bannerId: string): boolean => { + if (bannerId.startsWith("info-banner")) { + return (lastDismissedInfoBannerVersion ?? 0) >= CURRENT_INFO_BANNER_VERSION + } + if (bannerId.startsWith("new-model")) { + return (lastDismissedModelBannerVersion ?? 0) >= CURRENT_MODEL_BANNER_VERSION + } + if (bannerId.startsWith("cli-")) { + return (lastDismissedCliBannerVersion ?? 0) >= CURRENT_CLI_BANNER_VERSION + } + return false + }, + [lastDismissedInfoBannerVersion, lastDismissedModelBannerVersion, lastDismissedCliBannerVersion], + ) + /** * Banner configuration from backend * In production, this would come from an API/gRPC call @@ -61,6 +80,10 @@ export const WelcomeSection: React.FC = ({ const bannerConfig = useMemo((): BannerCardData[] => { // Filter banners based on version tracking and user status return BANNER_DATA.filter((banner) => { + if (isBannerDismissed(banner.id)) { + return false + } + if (banner.isClineUserOnly !== undefined) { return banner.isClineUserOnly === !!clineUser } @@ -71,7 +94,7 @@ export const WelcomeSection: React.FC = ({ return true }) - }, [lastDismissedInfoBannerVersion, lastDismissedCliBannerVersion, lastDismissedModelBannerVersion, clineUser]) + }, [isBannerDismissed, clineUser]) /** * Action handler - maps action types to actual implementations diff --git a/webview-ui/src/components/common/BannerCarousel.tsx b/webview-ui/src/components/common/BannerCarousel.tsx index 0dbd1d1c..79fe3469 100644 --- a/webview-ui/src/components/common/BannerCarousel.tsx +++ b/webview-ui/src/components/common/BannerCarousel.tsx @@ -22,24 +22,68 @@ interface BannerCarouselProps { banners: BannerData[] } +interface BannerCardContentProps { + banner: BannerData + isActive: boolean + isTransitioning: boolean + showDismissButton: boolean +} + +const BannerCardContent: React.FC = ({ banner, isActive, isTransitioning, showDismissButton }) => { + const [markdownContent, setMarkdown] = useRemark() + + useEffect(() => { + setMarkdown(typeof banner.description === "string" ? banner.description : "") + }, [banner.description, setMarkdown]) + + return ( +
+ {/* Title with optional icon */} +

+ {banner.icon} + {banner.title} +

+ + {/* Description */} +
+ {markdownContent} +
+ + {/* Action buttons */} + {banner.actions?.length ? ( +
+ {banner.actions.map((action) => ( + + ))} +
+ ) : null} +
+ ) +} + export const BannerCarousel: React.FC = ({ banners }) => { const [currentIndex, setCurrentIndex] = useState(0) const [isPaused, setIsPaused] = useState(false) const [isTransitioning, setIsTransitioning] = useState(false) const autoPlayIntervalRef = useRef(null) - const [currentBannerMarkdownText, setMarkdown] = useRemark() - // Compute a safe index that's always within bounds const safeCurrentIndex = useMemo( () => (banners.length === 0 ? 0 : Math.min(currentIndex, banners.length - 1)), [currentIndex, banners.length], ) - useEffect(() => { - setMarkdown(typeof banners?.[safeCurrentIndex]?.description === "string" ? banners[safeCurrentIndex].description : "") - }, [banners, safeCurrentIndex, setMarkdown]) - const transitionToIndex = useCallback((newIndex: number) => { setIsTransitioning(true) setTimeout(() => { @@ -98,22 +142,24 @@ export const BannerCarousel: React.FC = ({ banners }) => { return null } + const showDismissButton = safeCurrentIndex === banners.length - 1 && currentBanner.onDismiss + return (
setIsPaused(true)} onMouseLeave={() => setIsPaused(false)} role="region"> - {/* Card container with unified styling */} + {/* Card container */}
{/* Dismiss button - only show on last card, dismisses ALL banners */} - {safeCurrentIndex === banners.length - 1 && currentBanner.onDismiss && ( + {showDismissButton && ( )} - {/* Card content with fixed height and fade transition */} -
- {/* Title with optional icon */} -

- {currentBanner.icon} - {currentBanner.title} -

+ {/* Card content - grid stack makes container size to tallest */} +
+ {banners.map((banner, idx) => { + const isActive = idx === safeCurrentIndex + const isLastBanner = idx === banners.length - 1 + const showDismiss = isLastBanner && banner.onDismiss - {/* Description */} -
{currentBannerMarkdownText}
- - {/* Action buttons */} - {currentBanner.actions?.length ? ( -
- {currentBanner.actions.map((action, idx) => ( - - ))} -
- ) : null} + return ( + + ) + })}
{/* Navigation footer - only show if more than 1 banner */} {banners.length > 1 && ( -
+
{/* Page indicator */} -
- {safeCurrentIndex + 1}/{banners.length} +
+ {safeCurrentIndex + 1} / {banners.length}
{/* Navigation arrows */} -
- -