Misc bug fixes (#1895)

This commit is contained in:
pablodanswer
2024-07-22 10:22:43 -07:00
committed by GitHub
parent f91b92a898
commit 1276732409
12 changed files with 103 additions and 60 deletions

View File

@@ -64,7 +64,7 @@ class DiscourseConnector(PollConnector):
self.permissions: DiscoursePerms | None = None self.permissions: DiscoursePerms | None = None
self.active_categories: set | None = None self.active_categories: set | None = None
@rate_limit_builder(max_calls=100, period=60) @rate_limit_builder(max_calls=50, period=60)
def _make_request(self, endpoint: str, params: dict | None = None) -> Response: def _make_request(self, endpoint: str, params: dict | None = None) -> Response:
if not self.permissions: if not self.permissions:
raise ConnectorMissingCredentialError("Discourse") raise ConnectorMissingCredentialError("Discourse")

View File

@@ -14,15 +14,18 @@ export function ChatBanner() {
return ( return (
<div <div
className={` className={`
z-[39] mt-8
h-[30px] mb-2
bg-background-100 mx-2
shadow-sm z-[39]
m-2 w-full
rounded h-[30px]
border-border bg-background-100
border shadow-sm
flex`} rounded
border-border
border
flex`}
> >
<div className="mx-auto text-emphasis text-sm flex flex-col"> <div className="mx-auto text-emphasis text-sm flex flex-col">
<div className="my-auto"> <div className="my-auto">

View File

@@ -1203,6 +1203,23 @@ export function ChatPage({
currentChatSession={selectedChatSession} currentChatSession={selectedChatSession}
/> />
)} )}
<div className="w-full flex">
<div
style={{ transition: "width 0.30s ease-out" }}
className={`
flex-none
overflow-y-hidden
bg-background-100
transition-all
bg-opacity-80
duration-300
ease-in-out
h-full
${toggledSidebar || showDocSidebar ? "w-[300px]" : "w-[0px]"}
`}
/>
<ChatBanner />
</div>
{documentSidebarInitialWidth !== undefined ? ( {documentSidebarInitialWidth !== undefined ? (
<Dropzone onDrop={handleImageUpload} noClick> <Dropzone onDrop={handleImageUpload} noClick>
{({ getRootProps }) => ( {({ getRootProps }) => (
@@ -1231,8 +1248,7 @@ export function ChatPage({
ref={scrollableDivRef} ref={scrollableDivRef}
> >
{/* ChatBanner is a custom banner that displays a admin-specified message at {/* ChatBanner is a custom banner that displays a admin-specified message at
the top of the chat page. Only used in the EE version of the app. */} the top of the chat page. Oly used in the EE version of the app. */}
<ChatBanner />
{messageHistory.length === 0 && {messageHistory.length === 0 &&
!isFetchingChatMessages && !isFetchingChatMessages &&

View File

@@ -99,22 +99,28 @@ export const HistorySidebar = forwardRef<HTMLDivElement, HistorySidebarProps>(
h-screen h-screen
transition-transform`} transition-transform`}
> >
<div className="ml-4 mr-3 flex flex gap-x-1 items-center mt-2 my-auto text-text-700 text-xl"> <div className="max-w-full ml-3 mr-3 mt-2 flex flex gap-x-1 items-center my-auto text-text-700 text-xl">
<div className="mr-1 my-auto h-6 w-6"> <div className="mr-1 mb-auto h-6 w-6">
<Logo height={24} width={24} /> <Logo height={24} width={24} />
</div> </div>
<div className="invisible"> <div className="invisible">
{enterpriseSettings && enterpriseSettings.application_name ? ( {enterpriseSettings && enterpriseSettings.application_name ? (
<HeaderTitle>{enterpriseSettings.application_name}</HeaderTitle> <div>
<HeaderTitle>
{enterpriseSettings.application_name}
</HeaderTitle>
{!NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED && (
<p className="text-xs text-subtle">Powered by Danswer</p>
)}
</div>
) : ( ) : (
<HeaderTitle>Danswer</HeaderTitle> <HeaderTitle>Danswer</HeaderTitle>
)} )}
</div> </div>
{toggleSidebar && ( {toggleSidebar && (
<Tooltip delayDuration={1000} content={`${commandSymbol}E show`}> <Tooltip delayDuration={1000} content={`${commandSymbol}E show`}>
<button className="ml-auto" onClick={toggleSidebar}> <button className="mb-auto ml-auto" onClick={toggleSidebar}>
{!toggled ? <RightToLineIcon /> : <LefToLineIcon />} {!toggled ? <RightToLineIcon /> : <LefToLineIcon />}
</button> </button>
</Tooltip> </Tooltip>

View File

@@ -3,6 +3,7 @@
import { HeaderTitle } from "@/components/header/Header"; import { HeaderTitle } from "@/components/header/Header";
import { Logo } from "@/components/Logo"; import { Logo } from "@/components/Logo";
import { SettingsContext } from "@/components/settings/SettingsProvider"; import { SettingsContext } from "@/components/settings/SettingsProvider";
import { NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED } from "@/lib/constants";
import { useContext } from "react"; import { useContext } from "react";
export default function FixedLogo() { export default function FixedLogo() {
@@ -11,17 +12,24 @@ export default function FixedLogo() {
const enterpriseSettings = combinedSettings?.enterpriseSettings; const enterpriseSettings = combinedSettings?.enterpriseSettings;
return ( return (
<div className="absolute flex z-40 left-4 top-2"> <div className="absolute flex z-40 left-2.5 top-2">
{" "} <div className="max-w-[200px] flex gap-x-1 my-auto">
<a href="/chat" className="ml-7 text-text-700 text-xl"> <div className="flex-none invisible mb-auto">
<div> <Logo />
</div>
<div className="">
{enterpriseSettings && enterpriseSettings.application_name ? ( {enterpriseSettings && enterpriseSettings.application_name ? (
<HeaderTitle>{enterpriseSettings.application_name}</HeaderTitle> <div>
<HeaderTitle>{enterpriseSettings.application_name}</HeaderTitle>
{!NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED && (
<p className="text-xs text-subtle">Powered by Danswer</p>
)}
</div>
) : ( ) : (
<HeaderTitle>Danswer</HeaderTitle> <HeaderTitle>Danswer</HeaderTitle>
)} )}
</div> </div>
</a> </div>
</div> </div>
); );
} }

View File

@@ -10,12 +10,11 @@ const ToggleSwitch = () => {
const commandSymbol = KeyboardSymbol(); const commandSymbol = KeyboardSymbol();
const pathname = usePathname(); const pathname = usePathname();
const router = useRouter(); const router = useRouter();
const [activeTab, setActiveTab] = useState(() => { const [activeTab, setActiveTab] = useState(() => {
if (typeof window !== "undefined") { return pathname == "/search" ? "search" : "chat";
return localStorage.getItem("activeTab") || "chat";
}
return "chat";
}); });
const [isInitialLoad, setIsInitialLoad] = useState(true); const [isInitialLoad, setIsInitialLoad] = useState(true);
useEffect(() => { useEffect(() => {

View File

@@ -178,7 +178,7 @@ export default async function Home() {
: false; : false;
const agenticSearchEnabled = agenticSearchToggle const agenticSearchEnabled = agenticSearchToggle
? agenticSearchToggle.value.toLocaleLowerCase() == "true" || true ? agenticSearchToggle.value.toLocaleLowerCase() == "true" || false
: false; : false;
return ( return (

View File

@@ -31,7 +31,10 @@ export function Logo({
} }
return ( return (
<div style={{ height, width }} className={`relative ${className}`}> <div
style={{ height, width }}
className={`flex-none relative ${className}`}
>
{/* TODO: figure out how to use Next Image here */} {/* TODO: figure out how to use Next Image here */}
<img <img
src="/api/enterprise-settings/logo" src="/api/enterprise-settings/logo"

View File

@@ -91,7 +91,7 @@ export async function Layout({ children }: { children: React.ReactNode }) {
return ( return (
<div className="h-screen overflow-y-hidden"> <div className="h-screen overflow-y-hidden">
<div className="flex h-full"> <div className="flex h-full">
<div className="w-64 z-20 bg-background-100 pt-4 pb-8 h-full border-r border-border miniscroll overflow-auto"> <div className="w-64 z-20 bg-background-100 pt-3 pb-8 h-full border-r border-border miniscroll overflow-auto">
<AdminSidebar <AdminSidebar
collections={[ collections={[
{ {

View File

@@ -28,9 +28,9 @@ export function AdminSidebar({ collections }: { collections: Collection[] }) {
return ( return (
<aside className="pl-0"> <aside className="pl-0">
<nav className="space-y-2 pl-4"> <nav className="space-y-2 pl-2">
<div className="pb-12 flex"> <div className="mb-4 flex">
<div className="fixed left-0 top-0 py-2 pl-4 bg-background-100 w-[200px]"> <div className="bg-background-100">
<Link <Link
className="flex flex-col" className="flex flex-col"
href={ href={
@@ -39,8 +39,8 @@ export function AdminSidebar({ collections }: { collections: Collection[] }) {
: "/search" : "/search"
} }
> >
<div className="flex gap-x-1 my-auto"> <div className="max-w-[200px] flex gap-x-1 my-auto">
<div className="my-auto"> <div className="flex-none mb-auto">
<Logo /> <Logo />
</div> </div>
<div className="my-auto"> <div className="my-auto">
@@ -50,7 +50,7 @@ export function AdminSidebar({ collections }: { collections: Collection[] }) {
{enterpriseSettings.application_name} {enterpriseSettings.application_name}
</HeaderTitle> </HeaderTitle>
{!NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED && ( {!NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED && (
<p className="text-xs text-subtle -mt-1.5"> <p className="text-xs text-subtle">
Powered by Danswer Powered by Danswer
</p> </p>
)} )}
@@ -63,14 +63,16 @@ export function AdminSidebar({ collections }: { collections: Collection[] }) {
</Link> </Link>
</div> </div>
</div> </div>
<Link href={"/chat"}> <div className="px-3">
<button className="text-sm block w-48 py-2.5 flex px-2 text-left bg-background-200 hover:bg-background-200/80 cursor-pointer rounded"> <Link href={"/chat"}>
<BackIcon size={20} className="text-neutral" /> <button className="text-sm block w-48 py-2.5 flex px-2 text-left bg-background-200 hover:bg-background-200/80 cursor-pointer rounded">
<p className="ml-1">Back to Danswer</p> <BackIcon size={20} className="text-neutral" />
</button> <p className="ml-1">Back to Danswer</p>
</Link> </button>
</Link>
</div>
{collections.map((collection, collectionInd) => ( {collections.map((collection, collectionInd) => (
<div key={collectionInd}> <div className="px-3" key={collectionInd}>
<h2 className="text-xs text-strong font-bold pb-2"> <h2 className="text-xs text-strong font-bold pb-2">
<div>{collection.name}</div> <div>{collection.name}</div>
</h2> </h2>

View File

@@ -59,18 +59,23 @@ export default function FunctionalHeader({
<div className="pb-6 left-0 sticky top-0 z-10 w-full relative flex"> <div className="pb-6 left-0 sticky top-0 z-10 w-full relative flex">
<div className="mt-2 mx-4 text-text-700 flex w-full"> <div className="mt-2 mx-4 text-text-700 flex w-full">
<div className="absolute z-[100] my-auto flex items-center text-xl font-bold"> <div className="absolute z-[100] my-auto flex items-center text-xl font-bold">
<FiSidebar size={20} /> <div className="pt-[2px] mb-auto">
<div className="ml-2 text-text-700 text-xl"> <FiSidebar size={20} />
{enterpriseSettings && enterpriseSettings.application_name ? ( </div>
<HeaderTitle>{enterpriseSettings.application_name}</HeaderTitle> <div className="break-words inline-block w-fit ml-2 text-text-700 text-xl">
) : ( <div className="max-w-[200px]">
<HeaderTitle>Danswer</HeaderTitle> {enterpriseSettings && enterpriseSettings.application_name ? (
)} <HeaderTitle>{enterpriseSettings.application_name}</HeaderTitle>
) : (
<HeaderTitle>Danswer</HeaderTitle>
)}
</div>
</div> </div>
{page == "chat" && ( {page == "chat" && (
<Tooltip delayDuration={1000} content={`${commandSymbol}U`}> <Tooltip delayDuration={1000} content={`${commandSymbol}U`}>
<Link <Link
className="mb-auto pt-[2px]"
href={ href={
`/${page}` + `/${page}` +
(NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA && (NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA &&
@@ -79,10 +84,9 @@ export default function FunctionalHeader({
: "") : "")
} }
> >
<NewChatIcon <div className="cursor-pointer ml-2 flex-none text-text-700 hover:text-text-600 transition-colors duration-300">
size={20} <NewChatIcon size={20} className="" />
className="ml-2 my-auto cursor-pointer text-text-700 hover:text-text-600 transition-colors duration-300" </div>
/>
</Link> </Link>
</Tooltip> </Tooltip>
)} )}

View File

@@ -11,7 +11,11 @@ import { Logo } from "../Logo";
import { NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED } from "@/lib/constants"; import { NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED } from "@/lib/constants";
export function HeaderTitle({ children }: { children: JSX.Element | string }) { export function HeaderTitle({ children }: { children: JSX.Element | string }) {
return <h1 className="flex text-2xl text-strong font-bold">{children}</h1>; return (
<h1 className="flex text-2xl text-strong leading-none font-bold">
{children}
</h1>
);
} }
interface HeaderProps { interface HeaderProps {
@@ -36,8 +40,8 @@ export function Header({ user, page }: HeaderProps) {
settings && settings.default_page === "chat" ? "/chat" : "/search" settings && settings.default_page === "chat" ? "/chat" : "/search"
} }
> >
<div className="flex my-auto"> <div className="max-w-[200px] bg-black flex my-auto">
<div className="mr-1 my-auto"> <div className="mr-1 mb-auto">
<Logo /> <Logo />
</div> </div>
<div className="my-auto"> <div className="my-auto">
@@ -47,9 +51,7 @@ export function Header({ user, page }: HeaderProps) {
{enterpriseSettings.application_name} {enterpriseSettings.application_name}
</HeaderTitle> </HeaderTitle>
{!NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED && ( {!NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED && (
<p className="text-xs text-subtle -mt-1.5"> <p className="text-xs text-subtle">Powered by Danswer</p>
Powered by Danswer
</p>
)} )}
</div> </div>
) : ( ) : (