这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@shatfield4
Copy link
Collaborator

@shatfield4 shatfield4 commented Nov 29, 2023

Create down arrow that appears when chat is not scrolled to the bottom

@shatfield4 shatfield4 self-assigned this Nov 29, 2023
@review-agent-prime
Copy link

frontend/src/pages/OnboardingFlow/OnboardingModal/Steps/PasswordProtection/index.jsx

Instead of using alerts to display errors, consider using a more user-friendly approach such as a notification system or a dedicated error display component. This will improve the user experience and make the application more robust.
Create Issue
See the diff
Checkout the fix

    if (error) {
      // Replace this
      alert(`Failed to set password: ${error}`, "error");
      // With something like this
      displayError(`Failed to set password: ${error}`);
      return;
    }
git fetch origin && git checkout -b ReviewBot/Impro-9mjocs6 origin/ReviewBot/Impro-9mjocs6

frontend/src/components/Modals/NewWorkspace.jsx

Consider using destructuring to extract the values from the form data. This will make the code cleaner and easier to read.
Create Issue
See the diff
Checkout the fix

    // Replace this
    const data = {};
    const form = new FormData(formEl.current);
    for (var [key, value] of form.entries()) data[key] = value;
    // With something like this
    const form = new FormData(formEl.current);
    const data = Object.fromEntries(form);
git fetch origin && git checkout -b ReviewBot/Impro-kgupi0u origin/ReviewBot/Impro-kgupi0u

frontend/src/pages/OnboardingFlow/OnboardingModal/Steps/EmbeddingSelection/index.jsx

Consider using destructuring to extract the values from the form data. This will make the code cleaner and easier to read.
Create Issue
See the diff
Checkout the fix

    // Replace this
    const data = {};
    const formData = new FormData(form);
    for (var [key, value] of formData.entries()) data[key] = value;
    // With something like this
    const formData = new FormData(form);
    const data = Object.fromEntries(formData);
git fetch origin && git checkout -b ReviewBot/Impro-yg74npe origin/ReviewBot/Impro-yg74npe

frontend/src/pages/OnboardingFlow/OnboardingModal/Steps/MultiUserSetup/index.jsx

Consider using destructuring to extract the values from the form data. This will make the code cleaner and easier to read.
Create Issue
See the diff
Checkout the fix

    // Replace this
    const data = {
      username: formData.get("username"),
      password: formData.get("password"),
    };
    // With something like this
    const data = Object.fromEntries(formData);
git fetch origin && git checkout -b ReviewBot/Impro-i0ogklr origin/ReviewBot/Impro-i0ogklr

frontend/src/pages/OnboardingFlow/index.jsx

Consider using the useCallback hook to memoize the showModal function. This will ensure that the function is only re-created when one of its dependencies changes, thus preventing unnecessary re-renders.
Create Issue
See the diff
Checkout the fix

    const showModal = useCallback(() => {
      setModalVisible(true);
    }, []);
git fetch origin && git checkout -b ReviewBot/The-c-jpouywa origin/ReviewBot/The-c-jpouywa

frontend/src/pages/OnboardingFlow/OnboardingModal/Steps/AppearanceSetup/index.jsx

Consider using the useMemo hook to memoize the computation of the _initLogo prop. This will ensure that the computation is only re-run when one of its dependencies changes, thus preventing unnecessary re-renders.
Create Issue
See the diff
Checkout the fix

    const _initLogo = useMemo(() => useLogo(), []);
git fetch origin && git checkout -b ReviewBot/The-c-okojhp2 origin/ReviewBot/The-c-okojhp2

frontend/src/pages/OnboardingFlow/OnboardingModal/Steps/LLMSelection/index.jsx

Consider using the useMemo hook to memoize the computation of the currentStep prop. This will ensure that the computation is only re-run when one of its dependencies changes, thus preventing unnecessary re-renders.
Create Issue
See the diff
Checkout the fix

    const currentStep = useMemo(() => props.currentStep, []);
git fetch origin && git checkout -b ReviewBot/The-c-ko8g0a4 origin/ReviewBot/The-c-ko8g0a4

frontend/src/pages/OnboardingFlow/OnboardingModal/Steps/DataHandling/index.jsx

Consider using the useMemo hook to memoize the computation of the currentStep prop. This will ensure that the computation is only re-run when one of its dependencies changes, thus preventing unnecessary re-renders.
Create Issue
See the diff
Checkout the fix

    const currentStep = useMemo(() => props.currentStep, []);
git fetch origin && git checkout -b ReviewBot/The-c-rbeb9co origin/ReviewBot/The-c-rbeb9co

frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/index.jsx

Consider using the useMemo hook to memoize the computation of the history prop. This will ensure that the computation is only re-run when one of its dependencies changes, thus preventing unnecessary re-renders.
Create Issue
See the diff
Checkout the fix

    const history = useMemo(() => props.history, []);
git fetch origin && git checkout -b ReviewBot/The-c-o39vwy8 origin/ReviewBot/The-c-o39vwy8

frontend/src/pages/OnboardingFlow/OnboardingModal/Steps/VectorDatabaseConnection/index.jsx

Instead of using the alert function to display the error message, consider using a more user-friendly way to display the error message. This could be a modal or a toast notification. This will improve the user experience and make the error message more noticeable.
Create Issue
See the diff
Checkout the fix

    if (error) {
      // Replace the alert function with a more user-friendly way to display the error message
      displayError(`Failed to save settings: ${error}`);
      return;
    }
git fetch origin && git checkout -b ReviewBot/Impro-f79pd2z origin/ReviewBot/Impro-f79pd2z

The useEffect hook is currently fetching the system keys every time the currentStep changes. If the system keys do not change frequently, consider fetching them once when the component mounts. This will reduce the number of network requests and improve the performance of the component.
Create Issue
See the diff
Checkout the fix

    useEffect(() => {
      async function fetchKeys() {
        const _settings = await System.keys();
        setSettings(_settings);
        setVectorDB(_settings?.VectorDB || "lancedb");
        setLoading(false);
      }
      // Fetch the system keys once when the component mounts
      if (currentStep === "vector_database" && !settings) {
        fetchKeys();
      }
    }, [currentStep, settings]);
git fetch origin && git checkout -b ReviewBot/Impro-5xsparm origin/ReviewBot/Impro-5xsparm

Comment on lines 14 to 15
const form = new FormData(formEl.current);
for (var [key, value] of form.entries()) data[key] = value;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is modified to use destructuring to extract the values from the form data. This makes the code cleaner and easier to read.

Suggested change
const form = new FormData(formEl.current);
for (var [key, value] of form.entries()) data[key] = value;
const form = new FormData(formEl.current);
const data = Object.fromEntries(form.entries());

Comment on lines 16 to 18
function showModal() {
document?.getElementById(OnboardingModalId)?.showModal();
setModalVisible(true);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The showModal function is refactored to use the useCallback hook. This will prevent unnecessary re-renders by ensuring that the function is only re-created when one of its dependencies changes.

Suggested change
function showModal() {
document?.getElementById(OnboardingModalId)?.showModal();
setModalVisible(true);
}
const showModal = useCallback(() => {
setModalVisible(true);
}, []);

Comment on lines +3 to 9
import { useEffect, useRef, useState } from "react";
import { useManageWorkspaceModal } from "../../../Modals/MangeWorkspace";
import ManageWorkspace from "../../../Modals/MangeWorkspace";
import { ArrowDown } from "@phosphor-icons/react";
import debounce from "lodash.debounce";

export default function ChatHistory({ history = [], workspace }) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useMemo hook is used to memoize the computation of the history prop. This ensures that the computation is only re-run when one of its dependencies changes, thus preventing unnecessary re-renders.

Suggested change
import { useEffect, useRef, useState } from "react";
import { useManageWorkspaceModal } from "../../../Modals/MangeWorkspace";
import ManageWorkspace from "../../../Modals/MangeWorkspace";
import { ArrowDown } from "@phosphor-icons/react";
import debounce from "lodash.debounce";
export default function ChatHistory({ history = [], workspace }) {
import { useEffect, useRef, useState, useMemo } from "react";
export default function ChatHistory({ history = [], workspace }) {
const history = useMemo(() => props.history, []);
// rest of the code...

@shatfield4 shatfield4 marked this pull request as ready for review November 30, 2023 02:26
@timothycarambat
Copy link
Member

@shatfield4 Can you fix merge conflicts and split the arrow show function from the PFP stuff? Too much going on to parse for just PFP support and the arrow and I know I'm going to miss something here

Copy link
Member

@timothycarambat timothycarambat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment

@shatfield4 shatfield4 changed the title Additional features for better UX Add down arrow to scroll user to bottom of page Dec 4, 2023
@timothycarambat timothycarambat merged commit 7b30dd0 into master Dec 4, 2023
@timothycarambat timothycarambat deleted the nice-to-haves branch December 4, 2023 21:27
cabwds pushed a commit to cabwds/anything-llm that referenced this pull request Jul 3, 2025
* fix sizing of onboarding modals & lint

* fix extra scrolling on mobile onboarding flow

* added message to use desktop for onboarding

* linting

* add arrow to scroll to bottom (debounced) and fix chat scrolling to always scroll to very bottom on message history change

* fix for empty chat

* change mobile alert copy

* fix div with bullet points to use list-disc instead

---------

Co-authored-by: timothycarambat <rambat1010@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants