janhq / jan

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer. Multiple engine support (llama.cpp, TensorRT-LLM)
https://jan.ai/
GNU Affero General Public License v3.0
23.74k stars 1.38k forks source link

enhancement: ux local server page #4045

Closed urmauur closed 6 days ago

urmauur commented 6 days ago

Describe Your Changes

web/containers/ServerLogs/index.tsx

  1. Imports:

    • Added useRef and updated the import statement for ScrollArea.
  2. State:

    • Introduced new state variables:
      • listRef: Ref to access the div element of logs.
      • prevScrollTop: To keep track of previous scroll position.
      • isUserManuallyScrollingUp: To determine if the user is manually scrolling up.
  3. Callbacks:

    • Added a new callback function handleScroll to manage scroll events and prevent automatic scrolling when the user manually scrolls up.
  4. Effect:

    • Introduced an effect that automatically scrolls to the bottom of the logs whenever the list of logs changes, unless the user is manually scrolling up.
  5. JSX Changes:

    • Replaced the div with a ScrollArea component and added the ref listRef.
    • Added onScroll={handleScroll} to the ScrollArea.

web/screens/LocalServer/LocalServerCenterPanel/index.tsx

  1. Imports:

    • Removed the import for ScrollArea.
  2. JSX Changes:

    • Replaced the ScrollArea with a direct render of ServerLogs.

web/screens/LocalServer/LocalServerLeftPanel/index.tsx

  1. State:

    • Introduced new state variable isLoading to manage loading states.
  2. Callbacks and Effects:

    • Updated onStartServerClick, onToggleServer, and other relevant functions to include logic for setting the isLoading state.
  3. JSX Changes:

    • Modified the button text to reflect loading status ("Starting...") when isLoading is true.
    • Added disabled={isLoading || ...} to disable the button during loading or under certain error conditions.

Summary

Fixes Issues

https://github.com/user-attachments/assets/7f42da49-813a-4dfe-8afc-b54681c73948

Self Checklist

github-actions[bot] commented 6 days ago

Barecheck - Code coverage report

Total: 69.11% Your code coverage diff: -0.27% ▾
Uncovered files and lines
FileLines
web/containers/ServerLogs/index.tsx21-27, 29, 31-34, 42-44, 48-49, 52-53, 57, 60, 62, 64-65, 67-68, 70-72, 74-75, 79-81, 83, 86-89, 110, 123, 147