Skip to content

Commit 8963930

Browse files
authored
fix(web): resolve ai onboarding typecheck regressions (#4862)
1 parent 1e13ce6 commit 8963930

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useAutoTimelineSummaryShortcut.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const useAutoTimelineSummaryShortcut = () => {
100100
})
101101
const previousContextKeyRef = useRef<string | null>(null)
102102

103-
const isAllTimeline = isTimelineSummaryAutoContext({ view, entryId })
103+
const isAllTimeline = isTimelineSummaryAutoContext({ entryId })
104104

105105
const defaultShortcut = useMemo(() => {
106106
const shortcuts = aiSettings.shortcuts ?? []

apps/desktop/layer/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { previewBackPath } from "~/atoms/preview"
2020
import { useGeneralSettingKey } from "~/atoms/settings/general"
2121
import { useSubscriptionColumnShow } from "~/atoms/sidebar"
2222
import { ROUTE_ENTRY_PENDING } from "~/constants"
23+
import { useFeature } from "~/hooks/biz/useFeature"
2324
import { useFollow } from "~/hooks/biz/useFollow"
2425
import { getRouteParams, useRouteParams } from "~/hooks/biz/useRouteParams"
2526
import { useLoginModal } from "~/hooks/common"

apps/desktop/layer/renderer/src/modules/new-user-guide/ai-chat-pane.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { useEventCallback } from "usehooks-ts"
2121

2222
import { useI18n } from "~/hooks/common"
2323
import { ChatInput } from "~/modules/ai-chat/components/layouts/ChatInput"
24-
import { Messages } from "~/modules/ai-chat/components/layouts/ChatInterface"
2524
import { useAttachScrollBeyond } from "~/modules/ai-chat/hooks/useAttachScrollBeyond"
2625
import { useAutoScroll } from "~/modules/ai-chat/hooks/useAutoScroll"
2726
import {
@@ -35,11 +34,12 @@ import {
3534
} from "~/modules/ai-chat/store/hooks"
3635
import type { AIChatContextBlock, BizUIMessage } from "~/modules/ai-chat/store/types"
3736

37+
import { Messages } from "../ai-chat/components/layouts/Messages"
3838
import { RateLimitNotice } from "../ai-chat/components/layouts/RateLimitNotice"
3939
import { AIChatWaitingIndicator } from "../ai-chat/components/message/AIChatMessage"
4040
import { AIShortcutButton } from "../ai-chat/components/ui/AIShortcutButton"
4141
import { LexicalAIEditorNodes } from "../ai-chat/editor"
42-
import { isRateLimitError } from "../ai-chat/utils/error"
42+
import { computeRateLimitMessage } from "../ai-chat/utils/rate-limit"
4343
import { stepAtom } from "./store"
4444

4545
const SUGGESTION_KEYS = [
@@ -447,11 +447,10 @@ function AIChatInterface({ inputRef }: AIChatInterfaceProps) {
447447

448448
const shouldShowScrollToBottom = hasMessages && !isAtBottom
449449

450-
// Check if error is a rate limit error
451-
const hasRateLimitError = useMemo(() => isRateLimitError(error), [error])
450+
const rateLimitMessage = useMemo(() => computeRateLimitMessage(error, null), [error])
452451

453452
// Additional height for rate limit notice (~40px)
454-
const rateLimitExtraHeight = hasRateLimitError ? 40 : 0
453+
const rateLimitExtraHeight = rateLimitMessage ? 40 : 0
455454

456455
const messages = useMessages()
457456
const setStep = useSetAtom(stepAtom)
@@ -521,7 +520,7 @@ function AIChatInterface({ inputRef }: AIChatInterfaceProps) {
521520
)}
522521

523522
<div ref={bottomPanelRef} className={"px-6"}>
524-
{hasRateLimitError && error && <RateLimitNotice error={error} />}
523+
{rateLimitMessage && <RateLimitNotice message={rateLimitMessage} />}
525524
<ChatInput
526525
ref={inputRef}
527526
onSend={handleSendMessage}

apps/desktop/layer/renderer/src/modules/new-user-guide/feeds-selection-list.tsx

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { ScrollArea } from "@follow/components/ui/scroll-area/ScrollArea.js"
88
import { Tooltip, TooltipContent, TooltipTrigger } from "@follow/components/ui/tooltip/index.js"
99
import { cn } from "@follow/utils/utils"
10+
import { decode } from "@toon-format/toon"
1011
import type { PrimitiveAtom } from "jotai"
1112
import { useAtom, useAtomValue, useSetAtom, useStore } from "jotai"
1213
import { AnimatePresence, m } from "motion/react"
@@ -23,6 +24,22 @@ import { feedSelectionAtomsAtom, selectedFeedSelectionAtomsAtom } from "./store"
2324

2425
type FeedToSelect = Omit<FeedSelection, "selected">
2526

27+
const extractFeedsToSelect = (output: unknown): FeedToSelect[] => {
28+
if (!output) {
29+
return []
30+
}
31+
32+
if (typeof output === "string") {
33+
return decode(output) as unknown as FeedToSelect[]
34+
}
35+
36+
if (Array.isArray(output)) {
37+
return output as unknown as FeedToSelect[]
38+
}
39+
40+
return []
41+
}
42+
2643
export function FeedsSelectionList() {
2744
const chatMessages = useMessages()
2845

@@ -42,14 +59,14 @@ export function FeedsSelectionList() {
4259
function FeedSelectionOperationScreen() {
4360
const chatMessages = useMessages()
4461

45-
const feedsToSelect: FeedToSelect[] = useMemo(
46-
() =>
47-
// find the last message that has the tool
48-
chatMessages
49-
.findLast((m) => m.parts?.some((p) => p.type === "tool-onboardingGetTrendingFeeds"))
50-
?.parts?.findLast((p) => p.type === "tool-onboardingGetTrendingFeeds")?.output ?? [],
51-
[chatMessages],
52-
)
62+
const feedsToSelect: FeedToSelect[] = useMemo(() => {
63+
// find the last message that has the tool
64+
const output = chatMessages
65+
.findLast((m) => m.parts?.some((p) => p.type === "tool-onboardingGetTrendingFeeds"))
66+
?.parts?.findLast((p) => p.type === "tool-onboardingGetTrendingFeeds")?.output
67+
68+
return extractFeedsToSelect(output)
69+
}, [chatMessages])
5370

5471
const store = useStore()
5572
const atomList = useAtomValue(feedSelectionAtomsAtom)

0 commit comments

Comments
 (0)