mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 21:29:11 +00:00
Add merge migration and add a new button for new convo in sidebar
This commit is contained in:
@@ -17,23 +17,44 @@ import {
|
|||||||
KhojLogoType,
|
KhojLogoType,
|
||||||
KhojSearchLogo,
|
KhojSearchLogo,
|
||||||
} from "../logo/khojLogo";
|
} from "../logo/khojLogo";
|
||||||
import { Gear } from "@phosphor-icons/react/dist/ssr";
|
import { Plus, Gear, HouseSimple } from "@phosphor-icons/react";
|
||||||
import { Plus } from "@phosphor-icons/react";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import AllConversations from "../allConversations/allConversations";
|
import AllConversations from "../allConversations/allConversations";
|
||||||
import FooterMenu from "../navMenu/navMenu";
|
import FooterMenu from "../navMenu/navMenu";
|
||||||
import { useSidebar } from "@/components/ui/sidebar";
|
import { useSidebar } from "@/components/ui/sidebar";
|
||||||
import { useIsMobileWidth } from "@/app/common/utils";
|
import { useIsMobileWidth } from "@/app/common/utils";
|
||||||
import { UserPlusIcon } from "lucide-react";
|
import { UserPlusIcon } from "lucide-react";
|
||||||
import { useAuthenticatedData } from "@/app/common/auth";
|
import { useAuthenticatedData, UserProfile } from "@/app/common/auth";
|
||||||
import LoginPrompt from "../loginPrompt/loginPrompt";
|
import LoginPrompt from "../loginPrompt/loginPrompt";
|
||||||
|
|
||||||
|
async function openChat(userData: UserProfile | null | undefined) {
|
||||||
|
const unauthenticatedRedirectUrl = `/login?redirect=${encodeURIComponent(window.location.pathname)}`;
|
||||||
|
if (!userData) {
|
||||||
|
window.location.href = unauthenticatedRedirectUrl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(`/api/chat/sessions`, {
|
||||||
|
method: "POST",
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
if (response.status == 200) {
|
||||||
|
window.location.href = `/chat?conversationId=${data.conversation_id}`;
|
||||||
|
} else if (response.status == 403 || response.status == 401) {
|
||||||
|
window.location.href = unauthenticatedRedirectUrl;
|
||||||
|
} else {
|
||||||
|
alert("Failed to start chat session");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Menu items.
|
// Menu items.
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{
|
||||||
title: "New",
|
title: "Home",
|
||||||
url: "/",
|
url: "/",
|
||||||
icon: Plus,
|
icon: HouseSimple
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Agents",
|
title: "Agents",
|
||||||
@@ -125,6 +146,20 @@ export function AppSidebar(props: AppSidebarProps) {
|
|||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
)}
|
)}
|
||||||
|
{
|
||||||
|
<SidebarMenuItem className="p-0 m-0 list-none">
|
||||||
|
<SidebarMenuButton
|
||||||
|
asChild
|
||||||
|
variant={"default"}
|
||||||
|
onClick={() => openChat(data)}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<Plus />
|
||||||
|
<span>New</span>
|
||||||
|
</div>
|
||||||
|
</SidebarMenuButton>
|
||||||
|
</SidebarMenuItem>
|
||||||
|
}
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<SidebarMenuItem key={item.title} className="p-0 list-none m-0">
|
<SidebarMenuItem key={item.title} className="p-0 list-none m-0">
|
||||||
<SidebarMenuButton asChild>
|
<SidebarMenuButton asChild>
|
||||||
|
|||||||
12
src/khoj/database/migrations/0082_merge_20250121_1842.py
Normal file
12
src/khoj/database/migrations/0082_merge_20250121_1842.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Generated by Django 5.0.10 on 2025-01-21 18:42
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("database", "0081_agent_is_hidden_chatmodel_description_and_more"),
|
||||||
|
("database", "0081_merge_20250120_1633"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = []
|
||||||
Reference in New Issue
Block a user