Skip to content

Commit

Permalink
Add env variable to allow people to control what clicking on New Chat…
Browse files Browse the repository at this point in the history
… does
  • Loading branch information
Weves committed Mar 3, 2024
1 parent a8cc3d5 commit 563df1f
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions deployment/docker_compose/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ services:
dockerfile: Dockerfile
args:
- NEXT_PUBLIC_DISABLE_STREAMING=${NEXT_PUBLIC_DISABLE_STREAMING:-false}
- NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA=${NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA:-false}
depends_on:
- api_server
restart: always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ services:
dockerfile: Dockerfile
args:
- NEXT_PUBLIC_DISABLE_STREAMING=${NEXT_PUBLIC_DISABLE_STREAMING:-false}
- NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA=${NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA:-false}
depends_on:
- api_server
restart: always
Expand Down
1 change: 1 addition & 0 deletions deployment/docker_compose/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ services:
dockerfile: Dockerfile
args:
- NEXT_PUBLIC_DISABLE_STREAMING=${NEXT_PUBLIC_DISABLE_STREAMING:-false}
- NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA=${NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA:-false}
depends_on:
- api_server
restart: always
Expand Down
6 changes: 6 additions & 0 deletions web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ ENV NEXT_TELEMETRY_DISABLED 1
ARG NEXT_PUBLIC_DISABLE_STREAMING
ENV NEXT_PUBLIC_DISABLE_STREAMING=${NEXT_PUBLIC_DISABLE_STREAMING}

ARG NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA
ENV NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA=${NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA}

RUN npm run build

# Step 3. Production image, copy all the files and run next
Expand Down Expand Up @@ -70,6 +73,9 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
ARG NEXT_PUBLIC_DISABLE_STREAMING
ENV NEXT_PUBLIC_DISABLE_STREAMING=${NEXT_PUBLIC_DISABLE_STREAMING}

ARG NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA
ENV NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA=${NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA}

# Note: Don't expose ports here, Compose will handle that for us if necessary.
# If you want to run this without compose, specify the ports to
# expose via cli
Expand Down
20 changes: 18 additions & 2 deletions web/src/app/chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ export const Chat = ({

{documentSidebarInitialWidth !== undefined ? (
<>
<div className="w-full sm:relative h-screen pb-[140px]">
<div
className={`w-full sm:relative h-screen ${retrievalDisabled ? "pb-[111px]" : "pb-[140px]"}`}
>
<div
className={`w-full h-full ${HEADER_PADDING} flex flex-col overflow-y-auto overflow-x-hidden relative`}
ref={scrollableDivRef}
Expand Down Expand Up @@ -697,7 +699,21 @@ export const Chat = ({
selectedPersona &&
messageHistory.length === 0 &&
!isFetchingChatMessages && (
<div className="mx-auto px-4 w-searchbar-xs 2xl:w-searchbar-sm 3xl:w-searchbar grid gap-4 grid-cols-1 grid-rows-1 mt-4 md:grid-cols-2">
<div
className={`
mx-auto
px-4
w-searchbar-xs
2xl:w-searchbar-sm
3xl:w-searchbar
grid
gap-4
grid-cols-1
grid-rows-1
mt-4
md:grid-cols-2
mb-6`}
>
{livePersona.starter_messages.map((starterMessage, i) => (
<div key={i} className="w-full">
<StarterMessage
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/chat/ChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function ChatLayout({
<div className="flex relative bg-background text-default overflow-x-hidden">
<ChatSidebar
existingChats={chatSessions}
currentChatId={chatId}
currentChatSession={selectedChatSession}
user={user}
/>

Expand Down
22 changes: 17 additions & 5 deletions web/src/app/chat/sessionSidebar/ChatSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@ import { useRouter } from "next/navigation";
import { User } from "@/lib/types";
import { logout } from "@/lib/user";
import { BasicClickable, BasicSelectable } from "@/components/BasicClickable";
import Image from "next/image";
import { ChatSessionDisplay } from "./SessionDisplay";
import { ChatSession } from "../interfaces";
import { groupSessionsByDateRange } from "../lib";
import { HEADER_PADDING } from "@/lib/constants";
import {
HEADER_PADDING,
NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA,
} from "@/lib/constants";

interface ChatSidebarProps {
existingChats: ChatSession[];
currentChatId: number | null;
currentChatSession: ChatSession | null | undefined;
user: User | null;
}

export const ChatSidebar = ({
existingChats,
currentChatId,
currentChatSession,
user,
}: ChatSidebarProps) => {
const router = useRouter();
Expand Down Expand Up @@ -65,6 +67,8 @@ export const ChatSidebar = ({
};
}, []);

const currentChatId = currentChatSession?.id;

return (
<div
className={`
Expand All @@ -79,7 +83,15 @@ export const ChatSidebar = ({
transition-transform`}
id="chat-sidebar"
>
<Link href="/chat" className="mx-3 mt-5">
<Link
href={
"/chat" +
(NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA && currentChatSession
? `?personaId=${currentChatSession.persona_id}`
: "")
}
className="mx-3 mt-5"
>
<BasicClickable fullWidth>
<div className="flex text-sm">
<FiPlusSquare className="my-auto mr-2" /> New Chat
Expand Down
4 changes: 4 additions & 0 deletions web/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export const INTERNAL_URL = process.env.INTERNAL_URL || "http://127.0.0.1:8080";
export const NEXT_PUBLIC_DISABLE_STREAMING =
process.env.NEXT_PUBLIC_DISABLE_STREAMING?.toLowerCase() === "true";

export const NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA =
process.env.NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA?.toLowerCase() ===
"true";

export const GMAIL_AUTH_IS_ADMIN_COOKIE_NAME = "gmail_auth_is_admin";

export const GOOGLE_DRIVE_AUTH_IS_ADMIN_COOKIE_NAME =
Expand Down

0 comments on commit 563df1f

Please sign in to comment.