diff --git a/apps/nextjs/src/components/AppComponents/Chat/Chat/hooks/useAilaStreamingStatus.ts b/apps/nextjs/src/components/AppComponents/Chat/Chat/hooks/useAilaStreamingStatus.ts index ce54e3d3d..d6afc6ef9 100644 --- a/apps/nextjs/src/components/AppComponents/Chat/Chat/hooks/useAilaStreamingStatus.ts +++ b/apps/nextjs/src/components/AppComponents/Chat/Chat/hooks/useAilaStreamingStatus.ts @@ -20,7 +20,6 @@ function findStreamingSections(message: Message | undefined): { content: undefined, }; } - log.info("Parsing message content", message.content); const { content } = message; const regex = /"path":"\/([^/"]*)/g; const pathMatches = @@ -94,5 +93,10 @@ export const useAilaStreamingStatus = ({ log.info("ailaStreamingStatus set:", status); }, [status]); - return { status, streamingSection, streamingSections }; + return { + status, + streamingSection: + status === "StreamingLessonPlan" ? streamingSection : undefined, + streamingSections, + }; }; diff --git a/apps/nextjs/src/components/AppComponents/Chat/drop-down-section/index.tsx b/apps/nextjs/src/components/AppComponents/Chat/drop-down-section/index.tsx index 3ee9fbfca..182ad0df6 100644 --- a/apps/nextjs/src/components/AppComponents/Chat/drop-down-section/index.tsx +++ b/apps/nextjs/src/components/AppComponents/Chat/drop-down-section/index.tsx @@ -1,6 +1,6 @@ import { useEffect, useMemo, useRef } from "react"; -import { +import type { LessonPlanKeys, LessonPlanSectionWhileStreaming, } from "@oakai/aila/src/protocol/schema"; @@ -12,7 +12,7 @@ import { Icon } from "@/components/Icon"; import LoadingWheel from "@/components/LoadingWheel"; import Skeleton from "../../common/Skeleton"; -import { AilaStreamingStatus } from "../Chat/hooks/useAilaStreamingStatus"; +import type { AilaStreamingStatus } from "../Chat/hooks/useAilaStreamingStatus"; import ChatSection from "./chat-section"; const DropDownSection = ({ @@ -42,8 +42,7 @@ const DropDownSection = ({ const sectionTitleMemo = useMemo(() => sectionTitle(section), [section]); const isStreaming = - ailaStreamingStatus === "StreamingLessonPlan" && - streamingSection === section; + ailaStreamingStatus !== "Idle" && streamingSection === section; const isLoaded = !isStreaming && value !== undefined; diff --git a/apps/nextjs/src/hooks/useLessonPlanScrollManagement.ts b/apps/nextjs/src/hooks/useLessonPlanScrollManagement.ts index 849fa7a5d..378f994f9 100644 --- a/apps/nextjs/src/hooks/useLessonPlanScrollManagement.ts +++ b/apps/nextjs/src/hooks/useLessonPlanScrollManagement.ts @@ -116,7 +116,7 @@ export const useLessonPlanScrollManagement = ( // Trigger processing the scroll queue useEffect(() => { - if (streamingStatus === "StreamingLessonPlan") { + if (streamingStatus !== "Idle") { const intervalId = setInterval(() => { processScrollQueue(); }, 200); diff --git a/apps/nextjs/src/lib/lessonPlan/LessonPlanManager.ts b/apps/nextjs/src/lib/lessonPlan/LessonPlanManager.ts index 76721954c..cab503c31 100644 --- a/apps/nextjs/src/lib/lessonPlan/LessonPlanManager.ts +++ b/apps/nextjs/src/lib/lessonPlan/LessonPlanManager.ts @@ -1,13 +1,11 @@ -import { - PatchDocument, - applyLessonPlanPatch, -} from "@oakai/aila/src/protocol/jsonPatchProtocol"; -import { +import type { PatchDocument } from "@oakai/aila/src/protocol/jsonPatchProtocol"; +import { applyLessonPlanPatch } from "@oakai/aila/src/protocol/jsonPatchProtocol"; +import type { LessonPlanKeys, LooseLessonPlan, } from "@oakai/aila/src/protocol/schema"; import { aiLogger } from "@oakai/logger"; -import { Message } from "ai"; +import type { Message } from "ai"; import { createHash } from "crypto"; import { EventEmitter } from "events"; import { deepClone } from "fast-json-patch"; @@ -99,6 +97,7 @@ export class LessonPlanManager { } public onMessageUpdated(message: Message): void { + log.info("LessonPlanManager: onMessageUpdated"); if (message.role === "assistant") { this.applyPatches(message); }