From b708ecfb53faca35d10bb56b7e29292c0f2abff9 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 9 Sep 2025 20:11:19 +0530 Subject: [PATCH] fix: ui fixes --- .../app/components/logs/log-options.tsx | 2 +- .../app/components/sidebar/app-sidebar.tsx | 13 +++--- .../routes/{home.logs.tsx => home.inbox.tsx} | 28 +------------ apps/webapp/app/routes/onboarding.tsx | 6 +-- .../app/services/episodeFacts.server.ts | 41 +++++++++++++++++++ .../app/services/knowledgeGraph.server.ts | 3 ++ apps/webapp/app/services/prompts/nodes.ts | 1 - apps/webapp/app/utils/pathBuilder.ts | 4 +- 8 files changed, 58 insertions(+), 40 deletions(-) rename apps/webapp/app/routes/{home.logs.tsx => home.inbox.tsx} (73%) diff --git a/apps/webapp/app/components/logs/log-options.tsx b/apps/webapp/app/components/logs/log-options.tsx index 47e8135..c9b25d5 100644 --- a/apps/webapp/app/components/logs/log-options.tsx +++ b/apps/webapp/app/components/logs/log-options.tsx @@ -41,7 +41,7 @@ export const LogOptions = ({ id }: LogOptionsProps) => { useEffect(() => { if (deleteFetcher.state === "idle" && deleteFetcher.data?.success) { - redirect(`/home/logs`); + redirect(`/home/inbox`); } }, [deleteFetcher.state, deleteFetcher.data]); diff --git a/apps/webapp/app/components/sidebar/app-sidebar.tsx b/apps/webapp/app/components/sidebar/app-sidebar.tsx index a04e80f..58deb38 100644 --- a/apps/webapp/app/components/sidebar/app-sidebar.tsx +++ b/apps/webapp/app/components/sidebar/app-sidebar.tsx @@ -11,6 +11,7 @@ import { import { Activity, Columns3, + Inbox, LayoutGrid, MessageSquare, Network, @@ -24,7 +25,12 @@ import { ConversationList } from "../conversation"; const data = { navMain: [ { - title: "Conversation", + title: "Inbox", + url: "/home/inbox", + icon: Inbox, + }, + { + title: "Chat", url: "/home/conversation", icon: MessageSquare, }, @@ -38,11 +44,6 @@ const data = { url: "/home/space", icon: Columns3, }, - { - title: "Activity", - url: "/home/logs", - icon: Activity, - }, { title: "Integrations", url: "/home/integrations", diff --git a/apps/webapp/app/routes/home.logs.tsx b/apps/webapp/app/routes/home.inbox.tsx similarity index 73% rename from apps/webapp/app/routes/home.logs.tsx rename to apps/webapp/app/routes/home.inbox.tsx index 1c9a3ce..c3aa541 100644 --- a/apps/webapp/app/routes/home.logs.tsx +++ b/apps/webapp/app/routes/home.inbox.tsx @@ -11,7 +11,6 @@ import { ContributionGraph } from "~/components/activity/contribution-graph"; export default function LogsAll() { const [selectedSource, setSelectedSource] = useState(); const [selectedStatus, setSelectedStatus] = useState(); - const contributionFetcher = useFetcher(); const { logs, @@ -26,35 +25,10 @@ export default function LogsAll() { status: selectedStatus, }); - // Fetch contribution data on mount - useEffect(() => { - if (contributionFetcher.state === "idle" && !contributionFetcher.data) { - contributionFetcher.load("/api/v1/activity/contribution"); - } - }, [contributionFetcher]); - - // Get contribution data from fetcher - const contributionData = contributionFetcher.data?.success - ? contributionFetcher.data.data.contributionData - : []; - const totalActivities = contributionFetcher.data?.success - ? contributionFetcher.data.data.totalActivities - : 0; - const isContributionLoading = - contributionFetcher.state === "loading" || !contributionFetcher.data; - return ( <> - +
- {/* Contribution Graph */} -
- {isContributionLoading ? ( - - ) : ( - - )} -
{isInitialLoad ? ( <> diff --git a/apps/webapp/app/routes/onboarding.tsx b/apps/webapp/app/routes/onboarding.tsx index 6be8882..d1408d5 100644 --- a/apps/webapp/app/routes/onboarding.tsx +++ b/apps/webapp/app/routes/onboarding.tsx @@ -24,7 +24,7 @@ import { parse } from "@conform-to/zod"; import { type RawTriplet } from "~/components/graph/type"; import { addToQueue } from "~/lib/ingest.server"; import { EpisodeType } from "@core/types"; -import { activityPath } from "~/utils/pathBuilder"; +import { inboxPath } from "~/utils/pathBuilder"; const schema = z.object({ answers: z.string(), @@ -34,7 +34,7 @@ export async function loader({ request }: LoaderFunctionArgs) { const user = await requireUser(request); if (user.onboardingComplete) { - return redirect(activityPath()); + return redirect(inboxPath()); } return json({ user }); @@ -76,7 +76,7 @@ export async function action({ request }: ActionFunctionArgs) { userId, ); - return redirect("/home/logs"); + return redirect("/home/inbox"); } catch (e: any) { return json({ errors: { body: e.message } }, { status: 400 }); } diff --git a/apps/webapp/app/services/episodeFacts.server.ts b/apps/webapp/app/services/episodeFacts.server.ts index e589505..e97c066 100644 --- a/apps/webapp/app/services/episodeFacts.server.ts +++ b/apps/webapp/app/services/episodeFacts.server.ts @@ -43,3 +43,44 @@ export async function getEpisodeFacts(episodeUuid: string, userId: string) { }; } } + +export async function getDocumentFacts(documentId: string, userId: string) { + try { + const facts = await getEpisodeStatements({ + episodeUuid, + userId, + }); + + const invalidFacts = await getStatementsInvalidatedByEpisode({ + episodeUuid, + userId, + }); + + return { + success: true, + facts: facts.map((fact) => ({ + uuid: fact.uuid, + fact: fact.fact, + createdAt: fact.createdAt.toISOString(), + validAt: fact.validAt.toISOString(), + invalidAt: fact.invalidAt ? fact.invalidAt.toISOString() : null, + attributes: fact.attributes, + })), + invalidFacts: invalidFacts.map((fact) => ({ + uuid: fact.uuid, + fact: fact.fact, + createdAt: fact.createdAt.toISOString(), + validAt: fact.validAt.toISOString(), + invalidAt: fact.invalidAt ? fact.invalidAt.toISOString() : null, + attributes: fact.attributes, + })), + }; + } catch (error) { + console.error("Error fetching episode facts:", error); + return { + success: false, + error: "Failed to fetch episode facts", + facts: [], + }; + } +} diff --git a/apps/webapp/app/services/knowledgeGraph.server.ts b/apps/webapp/app/services/knowledgeGraph.server.ts index f7efd60..aee3f89 100644 --- a/apps/webapp/app/services/knowledgeGraph.server.ts +++ b/apps/webapp/app/services/knowledgeGraph.server.ts @@ -297,6 +297,8 @@ export class KnowledgeGraphService { previousEpisodes, ); + console.log(extractedNodes.map((node) => node.name)); + const extractedTime = Date.now(); logger.log(`Extracted entities in ${extractedTime - normalizedTime} ms`); @@ -440,6 +442,7 @@ export class KnowledgeGraphService { let entities: EntityNode[] = []; const outputMatch = responseText.match(/([\s\S]*?)<\/output>/); + if (outputMatch && outputMatch[1]) { responseText = outputMatch[1].trim(); const extractedEntities = JSON.parse(responseText || "{}").entities || []; diff --git a/apps/webapp/app/services/prompts/nodes.ts b/apps/webapp/app/services/prompts/nodes.ts index 4fe9af7..42e5266 100644 --- a/apps/webapp/app/services/prompts/nodes.ts +++ b/apps/webapp/app/services/prompts/nodes.ts @@ -113,7 +113,6 @@ You are given a conversation context and a CURRENT EPISODE. Your task is to extr - Text: "authentication system" → ❌ Extract: "authentication system" (should be "Authentication", "System") - Text: "payment service" → ❌ Extract: "payment service" (should be "Payment", "Service") -Format your response as a JSON object with the following structure: { "entities": [ diff --git a/apps/webapp/app/utils/pathBuilder.ts b/apps/webapp/app/utils/pathBuilder.ts index 53aa51e..8e17b30 100644 --- a/apps/webapp/app/utils/pathBuilder.ts +++ b/apps/webapp/app/utils/pathBuilder.ts @@ -14,8 +14,8 @@ export function dashboardPath() { return `/home/dashboard`; } -export function activityPath() { - return `/home/logs`; +export function inboxPath() { + return `/home/inbox`; } export function conversationPath() {