Very minor auth standardization (#4400)

This commit is contained in:
pablonyx
2025-04-01 11:46:49 -07:00
committed by Weves
parent 7491cdd0f0
commit 2a87837ce1
24 changed files with 4330 additions and 7904 deletions

View File

@@ -196,7 +196,9 @@ export function ChatPage({
setCurrentMessageFiles,
} = useDocumentsContext();
const defaultAssistantIdRaw = searchParams.get(SEARCH_PARAM_NAMES.PERSONA_ID);
const defaultAssistantIdRaw = searchParams?.get(
SEARCH_PARAM_NAMES.PERSONA_ID
);
const defaultAssistantId = defaultAssistantIdRaw
? parseInt(defaultAssistantIdRaw)
: undefined;
@@ -252,8 +254,8 @@ export function ChatPage({
);
const { user, isAdmin } = useUser();
const slackChatId = searchParams.get("slackChatId");
const existingChatIdRaw = searchParams.get("chatId");
const slackChatId = searchParams?.get("slackChatId");
const existingChatIdRaw = searchParams?.get("chatId");
const [showHistorySidebar, setShowHistorySidebar] = useState(false);
@@ -275,7 +277,7 @@ export function ChatPage({
const processSearchParamsAndSubmitMessage = (searchParamsString: string) => {
const newSearchParams = new URLSearchParams(searchParamsString);
const message = newSearchParams.get("user-prompt");
const message = newSearchParams?.get("user-prompt");
filterManager.buildFiltersFromQueryString(
newSearchParams.toString(),
@@ -284,7 +286,7 @@ export function ChatPage({
tags
);
const fileDescriptorString = newSearchParams.get(SEARCH_PARAM_NAMES.FILES);
const fileDescriptorString = newSearchParams?.get(SEARCH_PARAM_NAMES.FILES);
const overrideFileDescriptors: FileDescriptor[] = fileDescriptorString
? JSON.parse(decodeURIComponent(fileDescriptorString))
: [];
@@ -324,7 +326,7 @@ export function ChatPage({
: undefined
);
// Gather default temperature settings
const search_param_temperature = searchParams.get(
const search_param_temperature = searchParams?.get(
SEARCH_PARAM_NAMES.TEMPERATURE
);
@@ -551,7 +553,7 @@ export function ChatPage({
if (
newMessageHistory.length === 1 &&
!submitOnLoadPerformed.current &&
searchParams.get(SEARCH_PARAM_NAMES.SEEDED) === "true"
searchParams?.get(SEARCH_PARAM_NAMES.SEEDED) === "true"
) {
submitOnLoadPerformed.current = true;
const seededMessage = newMessageHistory[0].message;
@@ -572,11 +574,11 @@ export function ChatPage({
initialSessionFetch();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [existingChatSessionId, searchParams.get(SEARCH_PARAM_NAMES.PERSONA_ID)]);
}, [existingChatSessionId, searchParams?.get(SEARCH_PARAM_NAMES.PERSONA_ID)]);
useEffect(() => {
const userFolderId = searchParams.get(SEARCH_PARAM_NAMES.USER_FOLDER_ID);
const allMyDocuments = searchParams.get(
const userFolderId = searchParams?.get(SEARCH_PARAM_NAMES.USER_FOLDER_ID);
const allMyDocuments = searchParams?.get(
SEARCH_PARAM_NAMES.ALL_MY_DOCUMENTS
);
@@ -599,14 +601,14 @@ export function ChatPage({
}
}, [
userFolders,
searchParams.get(SEARCH_PARAM_NAMES.USER_FOLDER_ID),
searchParams.get(SEARCH_PARAM_NAMES.ALL_MY_DOCUMENTS),
searchParams?.get(SEARCH_PARAM_NAMES.USER_FOLDER_ID),
searchParams?.get(SEARCH_PARAM_NAMES.ALL_MY_DOCUMENTS),
addSelectedFolder,
clearSelectedItems,
]);
const [message, setMessage] = useState(
searchParams.get(SEARCH_PARAM_NAMES.USER_PROMPT) || ""
searchParams?.get(SEARCH_PARAM_NAMES.USER_PROMPT) || ""
);
const [completeMessageDetail, setCompleteMessageDetail] = useState<
@@ -1048,7 +1050,7 @@ export function ChatPage({
// Equivalent to `loadNewPageLogic`
useEffect(() => {
if (searchParams.get(SEARCH_PARAM_NAMES.SEND_ON_LOAD)) {
if (searchParams?.get(SEARCH_PARAM_NAMES.SEND_ON_LOAD)) {
processSearchParamsAndSubmitMessage(searchParams.toString());
}
}, [searchParams, router]);
@@ -1231,7 +1233,7 @@ export function ChatPage({
const isNewSession = chatSessionIdRef.current === null;
const searchParamBasedChatSessionName =
searchParams.get(SEARCH_PARAM_NAMES.TITLE) || null;
searchParams?.get(SEARCH_PARAM_NAMES.TITLE) || null;
if (isNewSession) {
currChatSessionId = await createChatSession(
@@ -1409,11 +1411,11 @@ export function ChatPage({
modelVersion:
modelOverride?.modelName ||
llmManager.currentLlm.modelName ||
searchParams.get(SEARCH_PARAM_NAMES.MODEL_VERSION) ||
searchParams?.get(SEARCH_PARAM_NAMES.MODEL_VERSION) ||
undefined,
temperature: llmManager.temperature || undefined,
systemPromptOverride:
searchParams.get(SEARCH_PARAM_NAMES.SYSTEM_PROMPT) || undefined,
searchParams?.get(SEARCH_PARAM_NAMES.SYSTEM_PROMPT) || undefined,
useExistingUserMessage: isSeededChat,
useLanggraph:
settings?.settings.pro_search_enabled &&