Skip to content

Commit

Permalink
quick ux update
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Feb 8, 2025
1 parent dd73fdc commit 6a73245
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
22 changes: 20 additions & 2 deletions web/src/app/chat/ChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,7 @@ export function ChatPage({
"Continue Generating (pick up exactly where you left off)",
});
};
const [uncaughtError, setUncaughtError] = useState<string | null>(null);

const onSubmit = async ({
messageIdToResend,
Expand Down Expand Up @@ -1549,8 +1550,23 @@ export function ChatPage({
}
);
} else if (Object.hasOwn(packet, "error")) {
error = (packet as StreamingError).error;
stackTrace = (packet as StreamingError).stack_trace;
if (
sub_questions.length > 0 &&
sub_questions
.filter((q) => q.level === 0)
.every((q) => q.is_stopped === true)
) {
setUncaughtError((packet as StreamingError).error);
updateChatState("input");
setAgenticGenerating(false);
setAlternativeGeneratingAssistant(null);
setSubmittedMessage("");
return;
// throw new Error((packet as StreamingError).error);
} else {
error = (packet as StreamingError).error;
stackTrace = (packet as StreamingError).stack_trace;
}
} else if (Object.hasOwn(packet, "message_id")) {
finalMessage = packet as BackendMessage;
} else if (Object.hasOwn(packet, "stop_reason")) {
Expand Down Expand Up @@ -2039,6 +2055,7 @@ export function ChatPage({
}

const data = await response.json();

router.push(data.redirect_url);
} catch (error) {
console.error("Error seeding chat from Slack:", error);
Expand Down Expand Up @@ -2633,6 +2650,7 @@ export function ChatPage({
{message.sub_questions &&
message.sub_questions.length > 0 ? (
<AgenticMessage
error={uncaughtError}
docSidebarToggled={
documentSidebarToggled &&
(selectedMessageForDocDisplay ==
Expand Down
7 changes: 7 additions & 0 deletions web/src/app/chat/message/AgenticMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const AgenticMessage = ({
agenticDocs,
secondLevelSubquestions,
toggleDocDisplay,
error,
}: {
docSidebarToggled?: boolean;
isImprovement?: boolean | null;
Expand Down Expand Up @@ -110,6 +111,7 @@ export const AgenticMessage = ({
regenerate?: (modelOverRide: LlmOverride) => Promise<void>;
setPresentingDocument?: (document: OnyxDocument) => void;
toggleDocDisplay?: (agentic: boolean) => void;
error?: string | null;
}) => {
const [noShowingMessage, setNoShowingMessage] = useState(isComplete);

Expand Down Expand Up @@ -483,6 +485,11 @@ export const AgenticMessage = ({
) : (
content
)}
{error && (
<p className="mt-2 text-red-700 text-sm my-auto">
{error}
</p>
)}
</div>
</div>
</>
Expand Down
21 changes: 14 additions & 7 deletions web/src/app/chat/message/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export const AIMessage = ({
setPresentingDocument,
index,
toggledDocumentSidebar,
removePadding,
}: {
index?: number;
shared?: boolean;
Expand Down Expand Up @@ -213,6 +214,7 @@ export const AIMessage = ({
overriddenModel?: string;
regenerate?: (modelOverRide: LlmOverride) => Promise<void>;
setPresentingDocument?: (document: OnyxDocument) => void;
removePadding?: boolean;
}) => {
const toolCallGenerating = toolCall && !toolCall.tool_result;

Expand Down Expand Up @@ -398,7 +400,9 @@ export const AIMessage = ({
<div
id={isComplete ? "onyx-ai-message" : undefined}
ref={trackedElementRef}
className={`py-5 ml-4 lg:px-5 relative flex `}
className={`py-5 ml-4 lg:px-5 relative flex
${removePadding && "!pl-24 -mt-12"}`}
>
<div
className={`mx-auto ${
Expand All @@ -407,11 +411,13 @@ export const AIMessage = ({
>
<div className={`lg:mr-12 ${!shared && "mobile:ml-0 md:ml-8"}`}>
<div className="flex">
<AssistantIcon
className="mobile:hidden"
size={24}
assistant={alternativeAssistant || currentPersona}
/>
{!removePadding && (
<AssistantIcon
className="mobile:hidden"
size={24}
assistant={alternativeAssistant || currentPersona}
/>
)}

<div className="w-full">
<div className="max-w-message-max break-words">
Expand Down Expand Up @@ -588,7 +594,8 @@ export const AIMessage = ({
)}
</div>

{handleFeedback &&
{!removePadding &&
handleFeedback &&
(isActive ? (
<div
className={`
Expand Down

0 comments on commit 6a73245

Please sign in to comment.