fix(ai-chat): update timeline summary context to include feedId and adjust interval constant
This commit is contained in:
parent
9a8228fc7a
commit
8f067e4d3a
|
|
@ -21,7 +21,7 @@ import { BlockSliceAction } from "../store/slices/block.slice"
|
|||
import type { AIChatContextBlock, SendingUIMessage } from "../store/types"
|
||||
import { isTimelineSummaryAutoContext } from "./useTimelineSummaryAutoContext"
|
||||
|
||||
const ONE_HOUR = 60 * 60 * 1000
|
||||
const INTERVAL = 3 * 60 * 60 * 1000
|
||||
|
||||
const buildSummaryMessage = (
|
||||
editor: LexicalEditor,
|
||||
|
|
@ -100,7 +100,7 @@ export const useAutoTimelineSummaryShortcut = () => {
|
|||
})
|
||||
const previousContextKeyRef = useRef<string | null>(null)
|
||||
|
||||
const isAllTimeline = isTimelineSummaryAutoContext({ view, entryId })
|
||||
const isAllTimeline = isTimelineSummaryAutoContext({ view, feedId, entryId })
|
||||
|
||||
const defaultShortcut = useMemo(() => {
|
||||
const shortcuts = aiSettings.shortcuts ?? []
|
||||
|
|
@ -227,7 +227,7 @@ export const useAutoTimelineSummaryShortcut = () => {
|
|||
|
||||
if (existingSession) {
|
||||
const lastUpdatedAt = existingSession.updatedAt?.getTime?.() ?? existingSession.updatedAt
|
||||
if (typeof lastUpdatedAt === "number" && now - lastUpdatedAt < ONE_HOUR) {
|
||||
if (typeof lastUpdatedAt === "number" && now - lastUpdatedAt < INTERVAL) {
|
||||
if (currentChatId !== existingSession.chatId) {
|
||||
await chatActions.switchToChat(existingSession.chatId)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,24 @@
|
|||
import { FeedViewType } from "@follow/constants"
|
||||
|
||||
import { ROUTE_ENTRY_PENDING } from "~/constants"
|
||||
import { ROUTE_ENTRY_PENDING, ROUTE_FEED_PENDING } from "~/constants"
|
||||
import type { BizRouteParams } from "~/hooks/biz/useRouteParams"
|
||||
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
|
||||
export type TimelineSummaryContextParams = Pick<BizRouteParams, "view" | "entryId">
|
||||
export type TimelineSummaryContextParams = Pick<BizRouteParams, "view" | "entryId" | "feedId">
|
||||
|
||||
export const isTimelineSummaryAutoContext = ({ view, entryId }: TimelineSummaryContextParams) => {
|
||||
return view === FeedViewType.All && (!entryId || entryId === ROUTE_ENTRY_PENDING)
|
||||
export const isTimelineSummaryAutoContext = ({
|
||||
view,
|
||||
feedId,
|
||||
entryId,
|
||||
}: TimelineSummaryContextParams) => {
|
||||
return (
|
||||
view === FeedViewType.All &&
|
||||
(!entryId || entryId === ROUTE_ENTRY_PENDING) &&
|
||||
(!feedId || feedId === ROUTE_FEED_PENDING)
|
||||
)
|
||||
}
|
||||
|
||||
export const useTimelineSummaryAutoContext = () =>
|
||||
useRouteParamsSelector(({ view, entryId }) => isTimelineSummaryAutoContext({ view, entryId }))
|
||||
useRouteParamsSelector(({ view, feedId, entryId }) =>
|
||||
isTimelineSummaryAutoContext({ view, feedId, entryId }),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue