diff --git a/apps/desktop/layer/renderer/src/atoms/settings/ai.ts b/apps/desktop/layer/renderer/src/atoms/settings/ai.ts index 36318ff73..1f2c086c8 100644 --- a/apps/desktop/layer/renderer/src/atoms/settings/ai.ts +++ b/apps/desktop/layer/renderer/src/atoms/settings/ai.ts @@ -7,11 +7,13 @@ import { atom, useAtomValue } from "jotai" export interface WebAISettings extends AISettings { panelStyle: AIChatPanelStyle + showSplineButton: boolean } export const createDefaultSettings = (): WebAISettings => ({ ...defaultAISettings, panelStyle: AIChatPanelStyle.Fixed, + showSplineButton: true, }) export const { diff --git a/apps/desktop/layer/renderer/src/components/ui/ai-summary-card/AISummaryCardBase.tsx b/apps/desktop/layer/renderer/src/components/ui/ai-summary-card/AISummaryCardBase.tsx index 85a83e1ed..11bdf738b 100644 --- a/apps/desktop/layer/renderer/src/components/ui/ai-summary-card/AISummaryCardBase.tsx +++ b/apps/desktop/layer/renderer/src/components/ui/ai-summary-card/AISummaryCardBase.tsx @@ -70,7 +70,7 @@ export const AISummaryCardBase: React.FC = ({ "group relative overflow-hidden rounded-2xl border border-neutral-200/50 p-5 backdrop-blur-xl", "bg-gradient-to-b from-neutral-50/80 to-white/40 dark:from-neutral-900/80 dark:to-neutral-900/40", "dark:border-neutral-800/50", - "shadow-[0_8px_32px_rgba(0,0,0,0.08)] dark:shadow-[0_8px_32px_rgba(0,0,0,0.3)]", + isLoading && "before:absolute before:inset-0 before:-z-10 before:animate-[pulse_2s_cubic-bezier(0.4,0,0.6,1)_infinite] before:bg-gradient-to-r before:from-purple-100/0 before:via-purple-300/10 before:to-purple-100/0 dark:before:from-purple-900/0 dark:before:via-purple-600/10 dark:before:to-purple-900/0", className, diff --git a/apps/desktop/layer/renderer/src/components/ui/modal/stacked/hooks.tsx b/apps/desktop/layer/renderer/src/components/ui/modal/stacked/hooks.tsx index 6c5c5ce2c..ca05383bb 100644 --- a/apps/desktop/layer/renderer/src/components/ui/modal/stacked/hooks.tsx +++ b/apps/desktop/layer/renderer/src/components/ui/modal/stacked/hooks.tsx @@ -165,7 +165,7 @@ export const useDialog = (): DialogInstance => { ), content: ({ dismiss }) => ( -
+
{options.message}
diff --git a/apps/desktop/layer/renderer/src/components/ui/peek-modal/EntryMoreActions.tsx b/apps/desktop/layer/renderer/src/components/ui/peek-modal/EntryMoreActions.tsx index 41fdae708..55f7cda64 100644 --- a/apps/desktop/layer/renderer/src/components/ui/peek-modal/EntryMoreActions.tsx +++ b/apps/desktop/layer/renderer/src/components/ui/peek-modal/EntryMoreActions.tsx @@ -49,7 +49,7 @@ export const EntryMoreActions: FC<{ entryId: string }> = ({ entryId }) => { return ( - + diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIModelIndicator.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIModelIndicator.tsx index 003b05aae..e6e3641b2 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIModelIndicator.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIModelIndicator.tsx @@ -66,7 +66,8 @@ export const AIModelIndicator = memo(({ className, onModelChange }: AIModelIndic ? "hover:bg-material-medium cursor-button" : "hover:bg-material-medium/50", "duration-200", - "gap-1.5 px-2 py-1 text-xs", + "gap-1.5 p-1 text-xs", + hasMultipleModels && "px-2", "bg-material-ultra-thin border-border/50", "text-text-secondary", diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AISmartSidebar.css b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AISmartSidebar.css new file mode 100644 index 000000000..fb0bdf4e0 --- /dev/null +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AISmartSidebar.css @@ -0,0 +1,60 @@ +/* CSS animations for AISmartSidebar (replacing motion/react) */ + +.ai-ambient-bar { + transform-origin: right center; + transition: + width 0.3s ease-out, + opacity 0.3s ease-out, + transform 0.3s ease-out; +} + +@keyframes ai-bar-pulse { + 0%, + 100% { + transform: scale(1); + } + 50% { + transform: scale(1.1); + } +} + +.ai-ambient-pulse { + animation: ai-bar-pulse 2s ease-in-out infinite; +} + +.ai-glow-blob { + transition: + opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1), + transform 0.3s cubic-bezier(0.22, 1, 0.36, 1); + will-change: transform, opacity; + border-radius: 9999px; +} + +.ai-prompt-container { + opacity: 0; + transform: translateX(20px); + transition: + opacity 0.25s cubic-bezier(0.22, 1, 0.36, 1), + transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); +} + +.ai-prompt-visible { + opacity: 1; + transform: translateX(0); +} + +@keyframes ai-dot-pulse-kf { + 0%, + 100% { + transform: scale(1); + opacity: 0.7; + } + 50% { + transform: scale(1.2); + opacity: 1; + } +} + +.ai-dot-pulse { + animation: ai-dot-pulse-kf 2s ease-in-out infinite; +} diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AISmartSidebar.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AISmartSidebar.tsx new file mode 100644 index 000000000..254b452ee --- /dev/null +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AISmartSidebar.tsx @@ -0,0 +1,117 @@ +// Replaced motion/react animations with CSS animations +import "./AISmartSidebar.css" + +import { Spring } from "@follow/components/constants/spring.js" +import { useMousePosition } from "@follow/components/hooks/useMouse.js" +import { AnimatePresence, m } from "motion/react" +import * as React from "react" +import { useEffect, useState } from "react" + +import { setAIPanelVisibility, useAIPanelVisibility } from "~/atoms/settings/ai" + +const AIAmbientSidebar: React.FC<{ onExpand: () => void }> = ({ onExpand }) => { + const [intensity, setIntensity] = useState(0) + const [showPrompt, setShowPrompt] = useState(false) + const isShowPromptRef = React.useRef(false) + const mousePosition = useMousePosition() + + useEffect(() => { + const rightEdgeDistance = window.innerWidth - mousePosition.x + const maxDistance = 500 + const threshold = 80 + const showedThreshold = 300 + const topBoundary = 100 + + if (mousePosition.y <= topBoundary) { + setIntensity(0) + setShowPrompt(false) + isShowPromptRef.current = false + return + } + + if (isShowPromptRef.current && rightEdgeDistance <= showedThreshold) { + return + } + + if (rightEdgeDistance <= maxDistance) { + const newIntensity = Math.max(0, (maxDistance - rightEdgeDistance) / maxDistance) + setIntensity(newIntensity) + const shouldShow = rightEdgeDistance <= threshold + setShowPrompt(shouldShow) + isShowPromptRef.current = shouldShow + } else { + setIntensity(0) + setShowPrompt(false) + isShowPromptRef.current = false + } + }, [mousePosition]) + + return ( + <> +
0.3 ? "ai-ambient-pulse" : "" + }`} + style={{ + opacity: intensity * 0.8, + width: intensity > 0 ? 8 + intensity * 40 : 2, + background: `linear-gradient(to left, rgba(255, 92, 0, ${intensity * 0.4}) 0%, rgba(255, 140, 0, ${intensity * 0.3}) 50%, transparent 100%)`, + }} + /> + + + {showPrompt && ( + <> + 0 ? -10 - intensity * 30 : 0, + }} + exit={{ opacity: 0, scale: 0.5, x: 0 }} + transition={Spring.presets.smooth} + className="ai-glow-blob pointer-events-none fixed bottom-12 right-0 z-40" + style={{ + opacity: intensity * 0.6, + transform: `translateX(${intensity > 0 ? -10 - intensity * 30 : 0}px) scale(${0.5 + intensity * 1.5})`, + width: 100, + height: 100, + background: `radial-gradient(circle, rgba(255, 92, 0, ${intensity * 0.3}) 0%, rgba(255, 140, 0, ${intensity * 0.2}) 40%, transparent 70%)`, + }} + /> + +
+
+

Ask AI anything

+

+ Get insights about this article +

+
+
+ + +
+ + )} +
+ + ) +} + +export const AISmartSidebar: React.FC = () => + !useAIPanelVisibility() && setAIPanelVisibility(true)} /> diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx index 62cb4cf2c..cc7643ecb 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx @@ -1,9 +1,9 @@ import { ActionButton } from "@follow/components/ui/button/index.js" +import clsx from "clsx" import type { ReactNode } from "react" import { useCallback } from "react" import { AIChatPanelStyle, setAIPanelVisibility, useAIChatPanelStyle } from "~/atoms/settings/ai" -import { GlassButton } from "~/components/ui/button/GlassButton" import { useBlockActions, useChatActions, useCurrentTitle } from "~/modules/ai-chat/store/hooks" import { ChatMoreDropdown } from "./ChatMoreDropdown" @@ -41,16 +41,23 @@ const ChatHeaderLayout = ({ [chatActions], ) - const maskImage = `linear-gradient(to bottom, black 0%, black 90%, transparent 100%)` + const isFloating = useAIChatPanelStyle() === AIChatPanelStyle.Floating + return ( -
-
+
+ {isFloating && ( +
+ )}
@@ -86,7 +93,7 @@ export const ChatHeader = () => { - + } /> @@ -110,27 +117,19 @@ export const ChatPageHeader = () => { ( <> - - - + + + - - - - } - /> +
- - + + + } /> diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInterface.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInterface.tsx index 72558aea8..7e0a54451 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInterface.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInterface.tsx @@ -283,7 +283,9 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => { "absolute mx-auto duration-500 ease-in-out", hasMessages && "inset-x-0 bottom-0 max-w-4xl px-6 pb-6", !hasMessages && "inset-x-0 bottom-0 max-w-3xl px-6 pb-6 duration-200", - centerInputOnEmpty && !hasMessages && "bottom-1/2 translate-y-full duration-200", + centerInputOnEmpty && + !hasMessages && + "bottom-1/2 translate-y-[calc(100%+1rem)] duration-200", )} > {error && } diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatMoreDropdown.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatMoreDropdown.tsx index a4b5f69b2..501caf850 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatMoreDropdown.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatMoreDropdown.tsx @@ -1,4 +1,4 @@ -import { useCallback, useState } from "react" +import { startTransition, useCallback, useState } from "react" import { useTranslation } from "react-i18next" import { toast } from "sonner" @@ -131,7 +131,7 @@ export const ChatMoreDropdown = ({ {sessions.map((session) => ( chatActions.switchToChat(session.chatId)} + onClick={() => startTransition(() => chatActions.switchToChat(session.chatId))} className="group flex h-12 cursor-pointer items-center justify-between rounded-md px-2 py-3" >
@@ -175,9 +175,9 @@ export const ChatMoreDropdown = ({ Export Chat + {canToggleMode && ( <> - -
+
{/* Header Section - Always Present */} = ({ className }) => { +export const AIIndicator: FC = () => { const panelStyle = useAIChatPanelStyle() const isVisible = useAIPanelVisibility() + const showSplineButton = useAISettingKey("showSplineButton") // Only show the spline button when: // 1. Panel style is floating @@ -30,7 +29,8 @@ export const AISplineButton: FC = ({ className }) => { return ( - {shouldShow && ( + {shouldShow && !showSplineButton && } + {shouldShow && showSplineButton && ( = ({ className }) => { whileTap={{ scale: 0.95 }} transition={Spring.presets.smooth} onClick={handleClick} - className={cn( + className={clsx( "fixed bottom-8 right-8 z-40", "size-16 rounded-2xl", - "backdrop-blur-xl", "hover:scale-105", "active:scale-95", "flex items-center justify-center", "transition-all duration-300 ease-out", - className, )} title="Open AI Chat" > diff --git a/apps/desktop/layer/renderer/src/modules/app-layout/subscription-column/SubscriptionColumn.tsx b/apps/desktop/layer/renderer/src/modules/app-layout/subscription-column/SubscriptionColumn.tsx index c4e80f099..6be754ca8 100644 --- a/apps/desktop/layer/renderer/src/modules/app-layout/subscription-column/SubscriptionColumn.tsx +++ b/apps/desktop/layer/renderer/src/modules/app-layout/subscription-column/SubscriptionColumn.tsx @@ -8,7 +8,6 @@ import { defaultUISettings } from "@follow/shared/settings/defaults" import { cn } from "@follow/utils" import { Slot } from "@radix-ui/react-slot" import { debounce } from "es-toolkit/compat" -import { AnimatePresence } from "motion/react" import type { PropsWithChildren } from "react" import * as React from "react" import { useEffect, useRef, useState } from "react" @@ -22,17 +21,12 @@ import { useTimelineColumnShow, useTimelineColumnTempShow, } from "~/atoms/sidebar" -import { m } from "~/components/common/Motion" import { FloatingLayerScope } from "~/constants" -import { useFeature } from "~/hooks/biz/useFeature" -import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry" -import { useRouteParams } from "~/hooks/biz/useRouteParams" import { useBatchUpdateSubscription } from "~/hooks/biz/useSubscriptionActions" import { useI18n } from "~/hooks/common" import { NetworkStatusIndicator } from "~/modules/app/NetworkStatusIndicator" import { COMMAND_ID } from "~/modules/command/commands/id" import { useCommandBinding } from "~/modules/command/hooks/use-command-binding" -import { useEntryContentScrollToTop } from "~/modules/entry-content/atoms" import { CornerPlayer } from "~/modules/player/corner-player" import { SubscriptionColumn } from "~/modules/subscription-column" import { getSelectedFeedIds, resetSelectedFeedIds } from "~/modules/subscription-column/atom" @@ -107,11 +101,8 @@ const FeedResponsiveResizerContainer = ({ }, }) - const aiEnabled = useFeature("ai") const feedColumnShow = useTimelineColumnShow() const feedColumnTempShow = useTimelineColumnTempShow() - const { entryId, isPendingEntry, view: currentView } = useRouteParams() - const navigate = useNavigateEntry() const t = useI18n() useEffect(() => { @@ -175,7 +166,6 @@ const FeedResponsiveResizerContainer = ({ timer = clearTimeout(timer) } }, [feedColumnShow]) - const isAtTop = !!useEntryContentScrollToTop() return ( <> @@ -195,27 +185,6 @@ const FeedResponsiveResizerContainer = ({ }} > {children} - - {/* Semi-transparent overlay with exit hint when in wide mode with entry selected */} - - {entryId && !isPendingEntry && aiEnabled && !isAtTop && ( - navigate({ entryId: null, view: currentView })} - initial={{ opacity: 0 }} - animate={{ opacity: 1 }} - exit={{ opacity: 0 }} - > -
-
- - {t("entry.exit_detail")} -
- {t("entry.click_to_return")} -
-
- )} -
{ const { entryId } = useParams() - const navigate = useNavigateEntry() + const panelStyle = useAIChatPanelStyle() const realEntryId = entryId === ROUTE_ENTRY_PENDING ? "" : entryId - // Swipe/scroll to close functionality - const entryContentRef = useRef(null) - const accumulatedDelta = useRef(0) - const isScrollingAtTop = useRef(false) - - const { view: currentView } = useRouteParams() - - const closeEntry = useCallback(() => { - navigate({ entryId: null, view: currentView }) - }, [navigate, currentView]) - - const handleCloseGesture = useCallback(() => { - closeEntry() - }, [closeEntry]) - - const handleWheel = useCallback( - (e: WheelEvent) => { - if (!realEntryId || !entryContentRef.current) return - - // Find the actual scroll viewport element with correct Radix UI attribute - const entryContentElement = entryContentRef.current.querySelector( - "[data-radix-scroll-area-viewport]", - ) as HTMLElement - const scrollElement = entryContentElement || entryContentRef.current - - // Check if we're at the top of the content - const scrollTop = scrollElement?.scrollTop || 0 - isScrollingAtTop.current = scrollTop === 0 - - // Handle trackpad/mouse wheel: upward scroll (deltaY < 0) or downward swipe gesture - // On macOS trackpad, natural scrolling makes upward finger movement negative deltaY - if (e.deltaY < 0 && isScrollingAtTop.current) { - e.preventDefault() - accumulatedDelta.current += Math.abs(e.deltaY) - - // Close when accumulated scroll exceeds threshold (150px for trackpad sensitivity) - if (accumulatedDelta.current > 1000) { - handleCloseGesture() - accumulatedDelta.current = 0 - setScrollToExitTutorialSeen(true) - } - } else { - // Reset accumulation when scrolling down or not at top - accumulatedDelta.current = 0 - } - }, - [realEntryId, handleCloseGesture], - ) - - useEffect(() => { - if (!realEntryId || !entryContentRef.current) return - - const element = entryContentRef.current - - // Find the scroll area viewport element with correct Radix UI attribute - const scrollViewport = element.querySelector("[data-radix-scroll-area-viewport]") as HTMLElement - - // Add wheel event listener to both the main container and scroll viewport - // This ensures the gesture works in both header area and scrollable content - const elementsToListen: HTMLElement[] = [element] - if (scrollViewport) { - elementsToListen.push(scrollViewport) - } - - elementsToListen.forEach((el) => { - el.addEventListener("wheel", handleWheel, { passive: false }) - }) - - return () => { - elementsToListen.forEach((el) => { - el.removeEventListener("wheel", handleWheel) - }) - } - }, [realEntryId, handleWheel]) - // AI chat resizable panel configuration const aiColWidth = useMemo(() => getUISettings().aiColWidth, []) const startDragPosition = useRef(0) @@ -131,14 +53,14 @@ const AIEntryLayoutImpl = () => { {/* Entry list - always rendered to prevent animation */} - + {/* Entry content overlay with exit animation */} + {realEntryId && ( @@ -181,7 +103,7 @@ export const AIEntryLayout = memo(function AIEntryLayout() { return ( - + ) }) diff --git a/apps/desktop/layer/renderer/src/modules/entry-column/components/mark-all-button.tsx b/apps/desktop/layer/renderer/src/modules/entry-column/components/mark-all-button.tsx index c8c417097..55a4e61b1 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-column/components/mark-all-button.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-column/components/mark-all-button.tsx @@ -1,5 +1,6 @@ import { useGlobalFocusableScopeSelector } from "@follow/components/common/Focusable/hooks.js" -import { ActionButton, Button } from "@follow/components/ui/button/index.js" +import { ActionButton } from "@follow/components/ui/button/index.js" +import { styledButtonVariant } from "@follow/components/ui/button/variants.js" import { Kbd, KbdCombined } from "@follow/components/ui/kbd/Kbd.js" import { useCountdown } from "@follow/hooks" import { EventBus } from "@follow/utils/event-bus" @@ -138,28 +139,18 @@ export const FlatMarkAllReadButton: FC< const { className, filter, which, buttonClassName, iconClassName } = props const [status, setStatus] = useState<"initial" | "confirm" | "done">("initial") - const animate = { - initial: { rotate: -30, opacity: 0.9 }, - exit: { rotate: -30, opacity: 0.9 }, - animate: { rotate: 0, opacity: 1 }, - } return ( - + ) } diff --git a/apps/desktop/layer/renderer/src/modules/entry-column/hooks/useWheelGestureClose.ts b/apps/desktop/layer/renderer/src/modules/entry-column/hooks/useWheelGestureClose.ts new file mode 100644 index 000000000..500b983e4 --- /dev/null +++ b/apps/desktop/layer/renderer/src/modules/entry-column/hooks/useWheelGestureClose.ts @@ -0,0 +1,100 @@ +import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js" +import { throttle } from "es-toolkit" +import { useEffect, useRef, useState } from "react" +import { useEventCallback } from "usehooks-ts" + +interface UseWheelGestureCloseOptions { + /** Whether the gesture is enabled */ + enabled: boolean + /** Callback to execute when close gesture is triggered */ + onClose: () => void +} + +interface UseWheelGestureCloseReturn { + /** Whether to show scroll hint indicator */ + showScrollHint: boolean +} + +/** + * Custom hook for handling wheel gesture to close entry + * Handles trackpad/mouse wheel upward scroll when at top of content + */ +export const useWheelGestureClose = ({ + enabled, + onClose: handleCloseGesture, +}: UseWheelGestureCloseOptions): UseWheelGestureCloseReturn => { + const $scrollAreaElement = useScrollViewElement() + const accumulatedDelta = useRef(0) + const isScrollingAtTop = useRef(false) + const [showScrollHint, setShowScrollHint] = useState(false) + + const handleWheel = useEventCallback( + throttle((e: WheelEvent) => { + if (!enabled) return + + // Find the actual scroll viewport element with correct Radix UI attribute + + const scrollElement = $scrollAreaElement + + // Check if we're at the top of the content + const scrollTop = scrollElement?.scrollTop || 0 + + isScrollingAtTop.current = scrollTop === 0 + setShowScrollHint(scrollTop === 0) + + // Handle trackpad/mouse wheel: upward scroll (deltaY < 0) or downward swipe gesture + // On macOS trackpad, natural scrolling makes upward finger movement negative deltaY + if (e.deltaY < 0 && isScrollingAtTop.current) { + e.preventDefault() + accumulatedDelta.current += Math.abs(e.deltaY) + + // Close when accumulated scroll exceeds threshold (150px for trackpad sensitivity) + if (accumulatedDelta.current > 1000) { + handleCloseGesture() + accumulatedDelta.current = 0 + } + } else { + // Reset accumulation when scrolling down or not at top + accumulatedDelta.current = 0 + } + }, 16), + ) + + useEffect(() => { + if (!$scrollAreaElement) return + // Find the scroll area viewport element with correct Radix UI attribute + + // Add wheel event listener to both the main container and scroll viewport + // This ensures the gesture works in both header area and scrollable content + const elementsToListen: HTMLElement[] = [$scrollAreaElement] + + elementsToListen.forEach((el) => { + el.addEventListener("wheel", handleWheel, { passive: false }) + }) + + // Initial scroll position check for hint visibility + const initialCheckScrollPosition = () => { + if (!$scrollAreaElement) return + const scrollTop = $scrollAreaElement.scrollTop || 0 + setShowScrollHint(scrollTop === 0) + } + + // Check initial position + initialCheckScrollPosition() + + // Add scroll listener for hint visibility + + $scrollAreaElement.addEventListener("scroll", initialCheckScrollPosition, { passive: true }) + + return () => { + elementsToListen.forEach((el) => { + el.removeEventListener("wheel", handleWheel) + }) + $scrollAreaElement.removeEventListener("scroll", initialCheckScrollPosition) + } + }, [$scrollAreaElement, handleWheel]) + + return { + showScrollHint, + } +} diff --git a/apps/desktop/layer/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx b/apps/desktop/layer/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx index 27c100104..fb1b5fc89 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx @@ -80,7 +80,7 @@ export const EntryListHeader: FC<{ return (
} + icon={} size={compact ? "xs" : "base"} /> diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/atoms.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/atoms.tsx index b7ce292d0..041154ede 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/atoms.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/atoms.tsx @@ -7,8 +7,12 @@ import { createAtomHooks } from "~/lib/jotai" export const [, , useEntryTitleMeta, , getEntryTitleMeta, setEntryTitleMeta] = createAtomHooks( atom( null as Nullable<{ - title: string - description: string + entryTitle: string + feedTitle: string + + // id-set + feedId: string + entryId: string }>, ), ) diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryTitle.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryTitle.tsx index f165eed76..f378b5bf8 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryTitle.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryTitle.tsx @@ -1,8 +1,7 @@ -import { useEntry, useEntryReadHistory } from "@follow/store/entry/hooks" +import { useEntry } from "@follow/store/entry/hooks" import { useFeedById } from "@follow/store/feed/hooks" import { useInboxById } from "@follow/store/inbox/hooks" import { useEntryTranslation } from "@follow/store/translation/hooks" -import { useWhoami } from "@follow/store/user/hooks" import { formatEstimatedMins, formatTimeToSeconds } from "@follow/utils" import { titleCase } from "title-case" import { useShallow } from "zustand/shallow" @@ -11,6 +10,7 @@ import { useShowAITranslation } from "~/atoms/ai-translation" import { useActionLanguage } from "~/atoms/settings/general" import { useUISettingKey } from "~/atoms/settings/ui" import { RelativeTime } from "~/components/ui/datetime" +import { useFeature } from "~/hooks/biz/useFeature" import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry" import { useFeedSafeUrl } from "~/hooks/common/useFeedSafeUrl" import type { FeedIconEntry } from "~/modules/feed/feed-icon" @@ -18,6 +18,7 @@ import { FeedIcon } from "~/modules/feed/feed-icon" import { getPreferredTitle } from "~/store/feed/hooks" import { EntryTranslation } from "../../entry-column/translation" +import { EntryReadHistory } from "./entry-read-history" interface EntryLinkProps { entryId: string @@ -25,7 +26,6 @@ interface EntryLinkProps { } export const EntryTitle = ({ entryId, compact }: EntryLinkProps) => { - const user = useWhoami() const entry = useEntry( entryId, useShallow((state) => { @@ -58,10 +58,11 @@ export const EntryTitle = ({ entryId, compact }: EntryLinkProps) => { }), ) + const aiEnabled = useFeature("ai") + const hideRecentReader = useUISettingKey("hideRecentReader") + const feed = useFeedById(entry?.feedId) const inbox = useInboxById(entry?.inboxId) - const data = useEntryReadHistory(entryId) - const entryHistory = data?.entryReadHistories const populatedFullHref = useFeedSafeUrl(entryId) const enableTranslation = useShowAITranslation() const actionLanguage = useActionLanguage() @@ -75,8 +76,6 @@ export const EntryTitle = ({ entryId, compact }: EntryLinkProps) => { const navigateEntry = useNavigateEntry() - const hideRecentReader = useUISettingKey("hideRecentReader") - if (!entry) return null return compact ? ( @@ -94,6 +93,16 @@ export const EntryTitle = ({ entryId, compact }: EntryLinkProps) => { ) : (
diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.ai.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.ai.tsx index a28c1a473..e7527d620 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.ai.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.ai.tsx @@ -30,6 +30,7 @@ import { BlockSliceAction } from "~/modules/ai-chat/store/slices/block.slice" import { COMMAND_ID } from "~/modules/command/commands/id" import { ApplyEntryActions } from "../../ApplyEntryActions" +import { setEntryContentScrollToTop } from "../../atoms" import { useEntryContent } from "../../hooks" import { AIEntryHeader } from "../entry-header" import { getEntryContentLayout } from "../layouts" @@ -69,7 +70,7 @@ const EntryContentImpl: Component = ({ const { error, content, isPending } = useEntryContent(entryId) const view = useRouteParamsSelector((route) => route.view) - const scrollerRef = useRef(null) + const [scrollerRef, setScrollerRef] = useState(null) const safeUrl = useFeedSafeUrl(entryId) const isZenMode = useIsZenMode() @@ -107,6 +108,24 @@ const EntryContentImpl: Component = ({ } }, [animationController, entryId]) + useEffect(() => { + setEntryContentScrollToTop(true) + }, [entryId]) + useEffect(() => { + if (!scrollerRef) return + + const handler = () => { + setEntryContentScrollToTop(scrollerRef.scrollTop < 50) + } + scrollerRef.addEventListener("scroll", handler) + + return () => { + scrollerRef.removeEventListener("scroll", handler) + } + }, [scrollerRef]) + + const scrollerRefObject = React.useMemo(() => ({ current: scrollerRef }), [scrollerRef]) + return (
@@ -124,13 +143,13 @@ const EntryContentImpl: Component = ({ > {/* */} - + + {/* */} {/* Indicator for the entry */} {!isZenMode && isInHasTimelineView && ( <> @@ -168,7 +187,7 @@ const EntryContentImpl: Component = ({
@@ -209,7 +228,7 @@ const EntryContentImpl: Component = ({ export const EntryContent = memo(EntryContentImpl) const EntryScrollArea: Component<{ - scrollerRef: React.RefObject + scrollerRef: React.Ref viewportClassName?: string }> = ({ children, className, scrollerRef, viewportClassName }) => { const isInPeekModal = useInPeekModal() diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.legacy.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.legacy.tsx index 915815a66..85a444157 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.legacy.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.legacy.tsx @@ -1,3 +1,4 @@ +import { useGlobalFocusableScopeSelector } from "@follow/components/common/Focusable/hooks.js" import { MemoedDangerousHTMLStyle } from "@follow/components/common/MemoedDangerousHTMLStyle.js" import { Spring } from "@follow/components/constants/spring.js" import { MotionButtonBase } from "@follow/components/ui/button/index.js" @@ -15,17 +16,18 @@ import { EventBus } from "@follow/utils/event-bus" import { clsx, cn } from "@follow/utils/utils" import { ErrorBoundary } from "@sentry/react" import type { JSAnimation, Variants } from "motion/react" -import { m, useAnimationControls } from "motion/react" +import { AnimatePresence, m, useAnimationControls } from "motion/react" import * as React from "react" import { memo, useEffect, useMemo, useRef, useState } from "react" import { useEntryIsInReadability } from "~/atoms/readability" import { useIsZenMode, useUISettingKey } from "~/atoms/settings/ui" -import { Focusable } from "~/components/common/Focusable" +import { Focusable, FocusablePresets } from "~/components/common/Focusable" import { ShadowDOM } from "~/components/common/ShadowDOM" import type { TocRef } from "~/components/ui/markdown/components/Toc" import { useInPeekModal } from "~/components/ui/modal/inspire/InPeekModal" import { HotkeyScope } from "~/constants" +import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry" import { useRenderStyle } from "~/hooks/biz/useRenderStyle" import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams" import { useFeedSafeUrl } from "~/hooks/common/useFeedSafeUrl" @@ -35,7 +37,9 @@ import { WrappedElementProvider } from "~/providers/wrapped-element-provider" import { AISummary } from "../../AISummary" import { ApplyEntryActions } from "../../ApplyEntryActions" +import { NAVIGATION_HINTS_ICONS, NAVIGATION_HINTS_TEXT } from "../../constants/navigation-hints" import { useEntryContent, useEntryMediaInfo } from "../../hooks" +import { useEntryNavigationHints } from "../../hooks/useEntryNavigationHints" import { EntryHeader } from "../entry-header" import { EntryAttachments } from "../EntryAttachments" import { EntryTimelineSidebar } from "../EntryTimelineSidebar" @@ -134,11 +138,11 @@ const EntryContentImpl: Component = ({ + {/* Indicator for the entry */} ) }) + +// EntryNavigationHandler for legacy version (without wheel gesture) +const EntryNavigationHandler = ({ entryId }: { entryId: string }) => { + const navigate = useNavigateEntry() + const when = useGlobalFocusableScopeSelector(FocusablePresets.isEntryRender) + + // Handle close gesture + const handleCloseEntry = React.useCallback(() => { + navigate({ entryId: null }) + }, [navigate]) + + // Navigation hints for entry content (legacy version without wheel gesture) + const { showFirstEntryHint, showScrollHint, showBottomHint } = useEntryNavigationHints({ + enabled: when && !!entryId, + entryId, + }) + + // Render hint button with different states + const renderHintButton = (icon: string, text: string, position: "top" | "bottom" = "top") => ( + + + + ) + + return ( + + {/* First entry hint */} + {showFirstEntryHint && + renderHintButton( + NAVIGATION_HINTS_ICONS.ARROW_UP, + NAVIGATION_HINTS_TEXT.SCROLL_UP_EXIT, + "top", + )} + + {/* Scroll threshold hint */} + {showScrollHint && + renderHintButton( + NAVIGATION_HINTS_ICONS.ARROW_UP, + NAVIGATION_HINTS_TEXT.SCROLL_UP_EXIT, + "top", + )} + + {/* Bottom hint */} + {showBottomHint && + renderHintButton(NAVIGATION_HINTS_ICONS.CLOSE, NAVIGATION_HINTS_TEXT.ESC_EXIT, "bottom")} + + ) +} diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryScrollingAndNavigationHandler.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryScrollingAndNavigationHandler.tsx index d8c6dd66b..7af53948f 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryScrollingAndNavigationHandler.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryScrollingAndNavigationHandler.tsx @@ -16,16 +16,13 @@ import { useEventCallback } from "usehooks-ts" import { FocusablePresets } from "~/components/common/Focusable" import { COMMAND_ID } from "~/modules/command/commands/id" import { useCommandBinding } from "~/modules/command/hooks/use-command-binding" -import { ScrollToExitTutorial } from "~/modules/entry-column/components/ScrollToExitTutorial" export const EntryScrollingAndNavigationHandler = ({ scrollerRef, scrollAnimationRef, - entryId, }: { scrollerRef: React.RefObject scrollAnimationRef: React.RefObject | null> - entryId: string }) => { const isAlreadyScrolledBottomRef = useRef(false) const [showKeepScrollingPanel, setShowKeepScrollingPanel] = useState(false) @@ -79,20 +76,11 @@ export const EntryScrollingAndNavigationHandler = ({ } } - const checkScrollBottomByWheel = () => { - isAlreadyScrolledBottomRef.current = false - setShowKeepScrollingPanel(false) - } - scrollerRef.current?.addEventListener("wheel", checkScrollBottomByWheel) - const cleanupScrollAnimation = () => { scrollAnimationRef.current?.stop() scrollAnimationRef.current = null } return combineCleanupFunctions( - () => { - scrollerRef.current?.removeEventListener("wheel", checkScrollBottomByWheel) - }, cleanupScrollAnimation, EventBus.subscribe(COMMAND_ID.entryRender.scrollUp, () => { const $scroller = scrollerRef.current @@ -175,9 +163,6 @@ export const EntryScrollingAndNavigationHandler = ({ )} - - {/* First-time user tutorial for scroll-to-exit */} - {!!entryId && } ) } diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryTitleMetaHandler.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryTitleMetaHandler.tsx index cfe2294c3..f8efdcba4 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryTitleMetaHandler.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryTitleMetaHandler.tsx @@ -1,11 +1,9 @@ import { useEntry } from "@follow/store/entry/hooks" import { useFeedById } from "@follow/store/feed/hooks" import { useInboxById } from "@follow/store/inbox/hooks" -import { useEffect, useLayoutEffect } from "react" +import { useEffect } from "react" -import { useIsSoFWrappedElement } from "~/providers/wrapped-element-provider" - -import { setEntryContentScrollToTop, setEntryTitleMeta } from "../../atoms" +import { setEntryTitleMeta } from "../../atoms" export const EntryTitleMetaHandler: Component<{ entryId: string @@ -20,21 +18,14 @@ export const EntryTitleMetaHandler: Component<{ const feed = useFeedById(entry?.feedId) const inbox = useInboxById(entry?.inboxId) const feedTitle = feed?.title || inbox?.title - const atTop = useIsSoFWrappedElement() - useEffect(() => { - setEntryContentScrollToTop(true) - }, [entryId]) - useLayoutEffect(() => { - setEntryContentScrollToTop(atTop) - }, [atTop]) useEffect(() => { if (entry?.title && feedTitle) { - setEntryTitleMeta({ title: entry.title, description: feedTitle }) + setEntryTitleMeta({ entryTitle: entry.title, feedTitle, feedId: entry.feedId!, entryId }) } return () => { setEntryTitleMeta(null) } - }, [entryId, entry?.title, feedTitle]) + }, [entryId, entry?.title, feedTitle, entry?.feedId]) return null } diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/AIEntryHeader.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/AIEntryHeader.tsx index e32149b4b..20c802540 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/AIEntryHeader.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/AIEntryHeader.tsx @@ -1,69 +1,24 @@ -import { Button } from "@follow/components/ui/button/index.js" -import { cn } from "@follow/utils" import { memo } from "react" -import { useTranslation } from "react-i18next" - -import { m } from "~/components/common/Motion" -import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry" -import { useEntryContentScrollToTop } from "~/modules/entry-content/atoms" +import { useEntryContentScrollToTop } from "../../atoms" import { EntryHeaderRoot } from "./internal/context" import { EntryHeaderActionsContainer } from "./internal/EntryHeaderActionsContainer" -import { EntryHeaderMeta } from "./internal/EntryHeaderMeta" -import { EntryHeaderReadHistory } from "./internal/EntryHeaderReadHistory" +import { EntryHeaderBreadcrumb } from "./internal/EntryHeaderBreadcrumb" import type { EntryHeaderProps } from "./types" function EntryHeaderImpl({ entryId, className, compact }: EntryHeaderProps) { - const { t } = useTranslation() - const navigate = useNavigateEntry() const isAtTop = useEntryContentScrollToTop() - return ( - <> - +
- {/* Scroll to exit hint - integrated into header to maintain consistent height */} - - - - -
- -
- - -
-
- - + + +
+
) } diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/index.ts b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/index.ts index ec16514a5..9bc1c6580 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/index.ts +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/index.ts @@ -3,5 +3,4 @@ export * from "./EntryHeader" export * from "./internal/context" export * from "./internal/EntryHeaderActionsContainer" export * from "./internal/EntryHeaderMeta" -export * from "./internal/EntryHeaderReadHistory" export * from "./types" diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderBreadcrumb.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderBreadcrumb.tsx new file mode 100644 index 000000000..f1d0049d4 --- /dev/null +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderBreadcrumb.tsx @@ -0,0 +1,294 @@ +import { ScrollArea } from "@follow/components/ui/scroll-area/index.js" +import { views } from "@follow/constants" +import { getEntry, getEntryIdsByFeedId } from "@follow/store/entry/getter" +import { useFeedById } from "@follow/store/feed/hooks" +import { useListById } from "@follow/store/list/hooks" +import { + getFeedSubscriptionByViewSelector, + getListSubscriptionByViewSelector, +} from "@follow/store/subscription/getter" +import type { + useFeedSubscriptionByView, + useListSubscriptionByView, +} from "@follow/store/subscription/hooks" +import { useSubscriptionStore } from "@follow/store/subscription/store" +import { cn } from "@follow/utils/utils" +import { useForceUpdate } from "motion/react" +import { useCallback, useRef } from "react" +import { useTranslation } from "react-i18next" + +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "~/components/ui/dropdown-menu/dropdown-menu" +import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry" +import { getRouteParams, useRouteParamsSelector } from "~/hooks/biz/useRouteParams" +import { getPreferredTitle } from "~/store/feed/hooks" + +import { useEntryTitleMeta } from "../../../atoms" +import { useEntryHeaderContext } from "./context" + +const Slash = ( + +) + +function ViewSubscriptionsDropdown({ + view, + onNavigate, +}: { + view: number + onNavigate: ReturnType +}) { + const feedSubsRef = useRef>([]) + const listSubsRef = useRef>([]) + const [forceUpdate] = useForceUpdate() + + const handleRefreshDropDownData = useCallback( + (open: boolean) => { + if (!open) return + + // Get fresh data from store + const state = useSubscriptionStore.getState() + const feedSubs = getFeedSubscriptionByViewSelector(state)(view) + const listSubs = getListSubscriptionByViewSelector(state)(view) + + feedSubsRef.current = feedSubs || [] + listSubsRef.current = listSubs || [] + + forceUpdate() + }, + [view, forceUpdate], + ) + + const routeParams = getRouteParams() + const { isAllFeeds, listId, feedId } = routeParams + + // Check if there's any subscription data for this view (without causing re-render) + // This allows initial render to show the dropdown if subscriptions exist + const state = useSubscriptionStore.getState() + const initialFeedSubs = getFeedSubscriptionByViewSelector(state)(view) + const initialListSubs = getListSubscriptionByViewSelector(state)(view) + const hasAnyInitial = (initialFeedSubs?.length ?? 0) + (initialListSubs?.length ?? 0) > 0 + + if (!hasAnyInitial) return null + + return ( + + + + + + +
+ onNavigate({ entryId: null, view })} + checked={isAllFeeds} + > + All + + {listSubsRef.current && listSubsRef.current.length > 0 && ( +
Lists
+ )} + {listSubsRef.current?.map((s) => + s.listId ? ( + s.listId && onNavigate({ entryId: null, listId: s.listId })} + > + + + ) : null, + )} + {feedSubsRef.current && feedSubsRef.current.length > 0 && ( +
Feeds
+ )} + {feedSubsRef.current?.map((s) => + s.feedId ? ( + s.feedId && onNavigate({ entryId: null, feedId: s.feedId })} + > + + + ) : null, + )} +
+
+
+
+ ) +} + +const ListNameItem = ({ listId }: { listId: string }) => { + const name = useListById(listId, (s) => s?.title) + if (!name) return null + return {name} +} + +const FeedNameItem = ({ feedId }: { feedId: string }) => { + const feed = useFeedById(feedId) + + if (!feed) return null + return {getPreferredTitle(feed)} +} + +function FeedEntriesDropdown({ + feedId, + currentEntryId, + onNavigate, +}: { + feedId: string + currentEntryId: string + onNavigate: ReturnType +}) { + const siblingEntriesRef = useRef<{ id: string; title: string }[]>([]) + const [forceUpdate] = useForceUpdate() + + const handleRefreshDropDownData = useCallback( + (open: boolean) => { + if (!open) return + + const entryIds = getEntryIdsByFeedId(feedId) + if (!entryIds) return + + siblingEntriesRef.current = [] + for (const entryId of entryIds) { + const entry = getEntry(entryId) + if (!entry) continue + const { title } = entry + if (!title) continue + siblingEntriesRef.current.push({ id: entryId, title }) + } + + forceUpdate() + }, + [feedId, forceUpdate], + ) + + // Check if there are any entries for this feed + const entryIds = getEntryIdsByFeedId(feedId) + if (!entryIds || entryIds.length <= 1) return null + + return ( + + + + + + +
+ {siblingEntriesRef.current.map((e) => ( + onNavigate({ entryId: e.id })} + checked={e.id === currentEntryId} + > + + {e.title} + + + ))} +
+
+
+
+ ) +} + +export function EntryHeaderBreadcrumb() { + const meta = useEntryTitleMeta() + + const navigate = useNavigateEntry() + const { entryId } = useEntryHeaderContext() + + const { t } = useTranslation() + const view = useRouteParamsSelector((s) => s.view) + if (!meta) return null + + return ( +
+ +
+ ) +} diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderMeta.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderMeta.tsx index 2abfe97ac..7f86d45e9 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderMeta.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderMeta.tsx @@ -6,7 +6,7 @@ import { useEntryContentScrollToTop, useEntryTitleMeta } from "../../../atoms" function EntryHeaderMetaImpl() { const entryTitleMeta = useEntryTitleMeta() const isAtTop = useEntryContentScrollToTop() - const shouldShowMeta = !isAtTop && !!entryTitleMeta?.title + const shouldShowMeta = !isAtTop && !!entryTitleMeta?.entryTitle return (
@@ -17,10 +17,10 @@ function EntryHeaderMetaImpl() { exit={{ opacity: 0.01, y: 30 }} className="text-text text-title3 flex min-w-0 flex-1 shrink items-end gap-2 truncate leading-tight" > - {entryTitleMeta.title} + {entryTitleMeta.entryTitle} - {entryTitleMeta.description} + {entryTitleMeta.feedTitle} )} diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/constants/navigation-hints.ts b/apps/desktop/layer/renderer/src/modules/entry-content/constants/navigation-hints.ts new file mode 100644 index 000000000..3264f4c5b --- /dev/null +++ b/apps/desktop/layer/renderer/src/modules/entry-content/constants/navigation-hints.ts @@ -0,0 +1,40 @@ +/** + * Constants for entry navigation hints behavior + */ +export const NAVIGATION_HINTS_CONSTANTS = { + /** Default scroll threshold to trigger scroll hint (px) */ + DEFAULT_SCROLL_THRESHOLD: 100, + + /** Delay before showing first entry hint (ms) */ + FIRST_HINT_DELAY: 500, + + /** Duration to show hints before auto-hiding (ms) */ + HINT_DISPLAY_DURATION: 3000, + + /** Distance from bottom to trigger bottom hint (px) */ + BOTTOM_THRESHOLD: 50, + + /** Distance from bottom to hide bottom hint when scrolling up (px) */ + BOTTOM_HIDE_THRESHOLD: 100, + + /** Throttle interval for scroll handler (ms) */ + SCROLL_THROTTLE_INTERVAL: 100, +} as const + +/** + * Text constants for navigation hints + */ +export const NAVIGATION_HINTS_TEXT = { + SCROLL_UP_EXIT: "Scroll up or click left-top back button to exit", + ESC_EXIT: "Press ESC or click left-top back button to exit", +} as const + +/** + * Icon constants for navigation hints + */ +export const NAVIGATION_HINTS_ICONS = { + ARROW_UP: "i-mgc-up-cute-re", + ARROW_LEFT_UP: "i-mingcute-arrow-left-up-line", + ARROW_TO_DOWN: "i-mingcute-arrow-to-down-line", + CLOSE: "i-mgc-close-cute-re", +} as const diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/hooks/useEntryNavigationHints.ts b/apps/desktop/layer/renderer/src/modules/entry-content/hooks/useEntryNavigationHints.ts new file mode 100644 index 000000000..7fd3e7483 --- /dev/null +++ b/apps/desktop/layer/renderer/src/modules/entry-content/hooks/useEntryNavigationHints.ts @@ -0,0 +1,201 @@ +import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js" +import { throttle } from "es-toolkit" +import { startTransition, useEffect, useRef, useState } from "react" +import { useEventCallback } from "usehooks-ts" + +import { NAVIGATION_HINTS_CONSTANTS } from "../constants/navigation-hints" + +interface UseEntryNavigationHintsOptions { + /** Whether hints are enabled */ + enabled: boolean + /** Entry ID to track changes */ + entryId?: string + /** Scroll threshold to show hint */ + scrollThreshold?: number +} + +interface UseEntryNavigationHintsReturn { + /** Show hint for first entry */ + showFirstEntryHint: boolean + /** Show hint when scrolled past threshold */ + showScrollHint: boolean + /** Show hint when at bottom */ + showBottomHint: boolean +} + +/** + * Custom hook for managing entry navigation hints + * Shows contextual hints based on scroll position and entry state + */ +export const useEntryNavigationHints = ({ + enabled, + entryId, + scrollThreshold = NAVIGATION_HINTS_CONSTANTS.DEFAULT_SCROLL_THRESHOLD, +}: UseEntryNavigationHintsOptions): UseEntryNavigationHintsReturn => { + const $scrollElement = useScrollViewElement() + + // State for different hint types + const [showFirstEntryHint, setShowFirstEntryHint] = useState(false) + const [showScrollHint, setShowScrollHint] = useState(false) + const [showBottomHint, setShowBottomHint] = useState(false) + + // Refs to track state + const hasShownFirstHintRef = useRef(false) + const hasShownScrollHintRef = useRef(false) + const hasShownBottomHintRef = useRef(false) + const currentEntryIdRef = useRef(void 0) + const firstHintTimerRef = useRef>(void 0) + const scrollHintTimerRef = useRef>(void 0) + const bottomHintTimerRef = useRef>(void 0) + const lastScrollTopRef = useRef(0) + const scrollDirectionRef = useRef<"up" | "down" | "none">("none") + + // Reset hints when entry changes + useEffect(() => { + if (entryId && entryId !== currentEntryIdRef.current) { + currentEntryIdRef.current = entryId + hasShownFirstHintRef.current = false + hasShownScrollHintRef.current = false + hasShownBottomHintRef.current = false + lastScrollTopRef.current = 0 + scrollDirectionRef.current = "none" + + // Clear existing timers + if (firstHintTimerRef.current) clearTimeout(firstHintTimerRef.current) + if (scrollHintTimerRef.current) clearTimeout(scrollHintTimerRef.current) + if (bottomHintTimerRef.current) clearTimeout(bottomHintTimerRef.current) + + // Reset all hint states with low priority + startTransition(() => { + setShowFirstEntryHint(false) + setShowScrollHint(false) + setShowBottomHint(false) + }) + + if (enabled) { + // Show first entry hint after a brief delay + firstHintTimerRef.current = setTimeout(() => { + if (!hasShownFirstHintRef.current) { + startTransition(() => { + setShowFirstEntryHint(true) + }) + hasShownFirstHintRef.current = true + + // Hide after configured duration + firstHintTimerRef.current = setTimeout(() => { + startTransition(() => { + setShowFirstEntryHint(false) + }) + }, NAVIGATION_HINTS_CONSTANTS.HINT_DISPLAY_DURATION) + } + }, NAVIGATION_HINTS_CONSTANTS.FIRST_HINT_DELAY) // Small delay to allow content to load + } + } + }, [entryId, enabled]) + + // Scroll handler to manage hints based on scroll position + const handleScroll = useEventCallback( + throttle(() => { + if (!enabled || !$scrollElement) return + + const { scrollTop } = $scrollElement + const { scrollHeight } = $scrollElement + const { clientHeight } = $scrollElement + const scrollBottom = scrollHeight - clientHeight - scrollTop + + // Detect scroll direction + const lastScrollTop = lastScrollTopRef.current + if (scrollTop > lastScrollTop) { + scrollDirectionRef.current = "down" + } else if (scrollTop < lastScrollTop) { + scrollDirectionRef.current = "up" + } + lastScrollTopRef.current = scrollTop + + // Check if scrolled past threshold and scrolling up + if ( + scrollTop > scrollThreshold && + !hasShownScrollHintRef.current && + scrollDirectionRef.current === "up" + ) { + hasShownScrollHintRef.current = true + startTransition(() => { + setShowScrollHint(true) + }) + + // Clear previous timer + if (scrollHintTimerRef.current) clearTimeout(scrollHintTimerRef.current) + + // Hide after configured duration + scrollHintTimerRef.current = setTimeout(() => { + startTransition(() => { + setShowScrollHint(false) + }) + }, NAVIGATION_HINTS_CONSTANTS.HINT_DISPLAY_DURATION) + } + + // Check if at bottom (within configured threshold) + if ( + scrollBottom <= NAVIGATION_HINTS_CONSTANTS.BOTTOM_THRESHOLD && + !hasShownBottomHintRef.current + ) { + hasShownBottomHintRef.current = true + startTransition(() => { + setShowBottomHint(true) + }) + + // Clear previous timer + if (bottomHintTimerRef.current) clearTimeout(bottomHintTimerRef.current) + + // Hide after configured duration + bottomHintTimerRef.current = setTimeout(() => { + startTransition(() => { + setShowBottomHint(false) + }) + hasShownBottomHintRef.current = false + }, NAVIGATION_HINTS_CONSTANTS.HINT_DISPLAY_DURATION) + } + + // Hide bottom hint if user scrolls up from bottom + if ( + scrollBottom > NAVIGATION_HINTS_CONSTANTS.BOTTOM_HIDE_THRESHOLD && + hasShownBottomHintRef.current && + scrollDirectionRef.current === "up" + ) { + // Clear timer if exists + if (bottomHintTimerRef.current) clearTimeout(bottomHintTimerRef.current) + + startTransition(() => { + setShowBottomHint(false) + }) + hasShownBottomHintRef.current = false + } + }, NAVIGATION_HINTS_CONSTANTS.SCROLL_THROTTLE_INTERVAL), + ) + + // Attach scroll listener + useEffect(() => { + if (!enabled || !$scrollElement) return + + $scrollElement.addEventListener("scroll", handleScroll, { passive: true }) + + return () => { + $scrollElement.removeEventListener("scroll", handleScroll) + } + }, [enabled, $scrollElement, handleScroll]) + + // Cleanup timers on unmount + useEffect(() => { + return () => { + if (firstHintTimerRef.current) clearTimeout(firstHintTimerRef.current) + if (scrollHintTimerRef.current) clearTimeout(scrollHintTimerRef.current) + if (bottomHintTimerRef.current) clearTimeout(bottomHintTimerRef.current) + } + }, []) + + return { + showFirstEntryHint, + showScrollHint, + showBottomHint, + } +} diff --git a/apps/desktop/layer/renderer/src/modules/settings/tabs/ai.tsx b/apps/desktop/layer/renderer/src/modules/settings/tabs/ai.tsx index b8f43da1b..6e63bdf72 100644 --- a/apps/desktop/layer/renderer/src/modules/settings/tabs/ai.tsx +++ b/apps/desktop/layer/renderer/src/modules/settings/tabs/ai.tsx @@ -30,6 +30,10 @@ export const SettingAI = () => { }, PanelStyleSection, + defineSettingItem("showSplineButton", { + label: t("settings.showSplineButton.label"), + description: t("settings.showSplineButton.description"), + }), defineSettingItem("autoScrollWhenStreaming", { label: t("settings.autoScrollWhenStreaming.label"), description: t("settings.autoScrollWhenStreaming.description"), diff --git a/apps/desktop/layer/renderer/src/modules/subscription-column/index.tsx b/apps/desktop/layer/renderer/src/modules/subscription-column/index.tsx index f31fa0c60..5f30107ad 100644 --- a/apps/desktop/layer/renderer/src/modules/subscription-column/index.tsx +++ b/apps/desktop/layer/renderer/src/modules/subscription-column/index.tsx @@ -138,7 +138,7 @@ export function SubscriptionColumn({ )} -
+
{ } return ( -
+
{ const navigateEntry = useNavigateEntry() return ( -
+
{ diff --git a/apps/desktop/layer/renderer/src/modules/subscription-column/subscription-list/SubscriptionList.tsx b/apps/desktop/layer/renderer/src/modules/subscription-column/subscription-list/SubscriptionList.tsx index 0926906a3..8a422a53f 100644 --- a/apps/desktop/layer/renderer/src/modules/subscription-column/subscription-list/SubscriptionList.tsx +++ b/apps/desktop/layer/renderer/src/modules/subscription-column/subscription-list/SubscriptionList.tsx @@ -244,7 +244,7 @@ const SubscriptionImpl = ({ ref, className, view, isSubscriptionLoading }: Subsc }} mask={false} flex - viewportClassName={cn("!px-3", shouldFreeUpSpace && "!overflow-visible")} + viewportClassName={cn("!px-1", shouldFreeUpSpace && "!overflow-visible")} rootClassName={cn("h-full", shouldFreeUpSpace && "overflow-visible")} > @@ -416,7 +416,7 @@ const useRegisterCommand = () => { } const SubscriptionListSkeleton = () => ( -
+
{Array.from({ length: 5 }).map((_, index) => (
diff --git a/apps/desktop/layer/renderer/src/pages/(main)/(layer)/(ai)/ai/index.tsx b/apps/desktop/layer/renderer/src/pages/(main)/(layer)/(ai)/ai/index.tsx index a60b8ec69..ef17f95a5 100644 --- a/apps/desktop/layer/renderer/src/pages/(main)/(layer)/(ai)/ai/index.tsx +++ b/apps/desktop/layer/renderer/src/pages/(main)/(layer)/(ai)/ai/index.tsx @@ -4,7 +4,10 @@ import { ChatInterface } from "~/modules/ai-chat/components/layouts/ChatInterfac export const Component = () => { return ( -
+
diff --git a/locales/ai/en.json b/locales/ai/en.json index fadd4e698..e3c8dcd75 100644 --- a/locales/ai/en.json +++ b/locales/ai/en.json @@ -122,6 +122,8 @@ "settings.panel_style.fixed": "Fixed", "settings.panel_style.floating": "Floating", "settings.panel_style.label": "Panel Style", + "settings.showSplineButton.description": "Show or hide the AI assistant indicator in the bottom-right corner", + "settings.showSplineButton.label": "AI Assistant Indicator", "settings.title": "AI Settings", "shortcuts.add": "Add Shortcut", "shortcuts.added": "Shortcut added successfully", diff --git a/packages/internal/components/src/constants/spring.ts b/packages/internal/components/src/constants/spring.ts index b93ba7529..0d3d3d049 100644 --- a/packages/internal/components/src/constants/spring.ts +++ b/packages/internal/components/src/constants/spring.ts @@ -1,5 +1,4 @@ import type { Transition } from "motion/react" - /** * A smooth spring with a predefined duration and no bounce. */