diff --git a/apps/web/ee/components/pi-chat/conversation/ai-message.tsx b/apps/web/ee/components/pi-chat/conversation/ai-message.tsx index be91ecc201..7c2f319db7 100644 --- a/apps/web/ee/components/pi-chat/conversation/ai-message.tsx +++ b/apps/web/ee/components/pi-chat/conversation/ai-message.tsx @@ -20,9 +20,10 @@ type TProps = { isPiThinking?: boolean; isLoading?: boolean; feedback?: EFeedback; + isLatest?: boolean; }; export const AiMessage = observer((props: TProps) => { - const { message = "", reasoning, isPiThinking = false, id, isLoading = false, feedback } = props; + const { message = "", reasoning, isPiThinking = false, id, isLoading = false, feedback, isLatest } = props; // store const { workspaceSlug } = useParams(); const { sendFeedback, activeChatId, isPiTyping } = usePiChat(); @@ -65,42 +66,36 @@ export const AiMessage = observer((props: TProps) => {
{/* Message */} - {!isPiThinking && !isLoading && ( -
- {reasoning && } - ( - - {children} - - ), - table: ({ children }) => ( -
- {children}
-
- ), - th: ({ children }) => {children}, - td: ({ children }) => {children}, - }} - > - {message} -
-
- )} - - {/* Typing */} - {isPiThinking && } - +
+ {!isLoading && } + ( + + {children} + + ), + table: ({ children }) => ( +
+ {children}
+
+ ), + th: ({ children }) => {children}, + td: ({ children }) => {children}, + }} + > + {message} +
+
{isLoading && ( )} {/* Action bar */} - {!isPiTyping && !isPiThinking && !isLoading && ( + {message && (
{/* Copy */} diff --git a/apps/web/ee/components/pi-chat/conversation/messages.tsx b/apps/web/ee/components/pi-chat/conversation/messages.tsx index 6796d0820b..845b8a5b98 100644 --- a/apps/web/ee/components/pi-chat/conversation/messages.tsx +++ b/apps/web/ee/components/pi-chat/conversation/messages.tsx @@ -81,18 +81,16 @@ export const Messages = observer((props: TProps) => { {activeChat?.dialogue?.map((message: TDialogue, index: number) => (
- {(message.answer || message.reasoning) && ( - - )} +
))} - {/* Typing */} - {isPiThinking && } {/* Loading */} {isLoading && } diff --git a/apps/web/ee/components/pi-chat/conversation/reasoning.tsx b/apps/web/ee/components/pi-chat/conversation/reasoning.tsx index 1cbc10a158..26cd6700f4 100644 --- a/apps/web/ee/components/pi-chat/conversation/reasoning.tsx +++ b/apps/web/ee/components/pi-chat/conversation/reasoning.tsx @@ -6,11 +6,11 @@ import { Thinking } from "./thinking"; type TProps = { reasoning: string | undefined; - isReasoning: boolean; + showLoading?: boolean; }; export const ReasoningBlock = (props: TProps) => { - const { reasoning, isReasoning } = props; + const { reasoning, showLoading } = props; const [isOpen, setIsOpen] = useState(false); return ( @@ -21,7 +21,7 @@ export const ReasoningBlock = (props: TProps) => { className="w-fit hover:bg-custom-background-90 rounded-full px-4 py-2 transition-all duration-500 ease-in-out border border-custom-border-200 hover:border-transparent" >
- {isReasoning ? ( + {showLoading ? ( ) : (
{isOpen ? "Hide" : "Show"} thinking
diff --git a/apps/web/ee/components/pi-chat/conversation/thinking.tsx b/apps/web/ee/components/pi-chat/conversation/thinking.tsx index b75fb12280..8556a20999 100644 --- a/apps/web/ee/components/pi-chat/conversation/thinking.tsx +++ b/apps/web/ee/components/pi-chat/conversation/thinking.tsx @@ -1,8 +1,8 @@ import Typing from "./typing"; -export const Thinking = () => ( +export const Thinking = ({ text = "Thinking" }: { text?: string }) => (
- Thinking   + {text}  
); diff --git a/apps/web/ee/store/pi-chat/pi-chat.ts b/apps/web/ee/store/pi-chat/pi-chat.ts index e39045fc39..1414872b0c 100644 --- a/apps/web/ee/store/pi-chat/pi-chat.ts +++ b/apps/web/ee/store/pi-chat/pi-chat.ts @@ -204,12 +204,12 @@ export class PiChatStore implements IPiChatStore { let payload: TInitPayload = { workspace_in_context: focus.isInWorkspaceContext, is_project_chat: isProjectChat, + workspace_id: workspaceId, }; if (focus.isInWorkspaceContext) { payload = { ...payload, [focus.entityType]: focus.entityIdentifier, - workspace_id: workspaceId, }; } @@ -252,6 +252,7 @@ export class PiChatStore implements IPiChatStore { // 🔹 Handles `delta` chunks eventSource.addEventListener("delta", (event: MessageEvent) => { try { + if (this.isPiThinkingMap[chatId]) this.isPiThinkingMap[chatId] = false; const data = JSON.parse(event.data); callback("answer", data.chunk); } catch (e) { @@ -268,9 +269,6 @@ export class PiChatStore implements IPiChatStore { console.error("Reasoning parse error", e); } }); - eventSource.onopen = () => { - if (this.isPiThinkingMap[chatId]) this.isPiThinkingMap[chatId] = false; - }; // 🔹 Handles done event eventSource.addEventListener("done", async () => {