feat: add toggle for conversation control sidebar (#546) #none

This commit is contained in:
Tuan Anh Nguyen Dang (Tadashi_Cin) 2024-12-04 07:53:28 +07:00 committed by GitHub
parent ab6b3fc529
commit a1fecfac45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 52 additions and 4 deletions

View File

@ -97,7 +97,7 @@ button.selected {
#chat-info-panel {
max-height: var(--main-area-height) !important;
overflow: auto !important;
transition: all 0.5s;
transition: all 0.4s;
}
body.dark #chat-info-panel figure>img{
@ -109,12 +109,12 @@ body.dark #chat-info-panel figure>img{
flex-wrap: unset;
overflow-y: scroll !important;
position: sticky;
min-width: min(305px, 100%) !important;
column-gap: 2px !important;
scrollbar-width: none;
/* Firefox */
-ms-overflow-style: none;
/* Internet Explorer 10+ */
transition: all 0.3s;
}
#conv-settings-panel::-webkit-scrollbar {
@ -204,6 +204,13 @@ mark {
right: 15px;
}
#chat-expand-button {
position: absolute;
top: 6px;
right: -10px;
z-index: 10;
}
#use-mindmap-checkbox {
position: absolute;
width: 110px;

View File

@ -0,0 +1 @@
<svg class="svg-icon" style="width: 24; height: 24;vertical-align: middle;fill: none;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path fill="#cecece" fill-rule="evenodd" d="M853.333333 213.333333a42.666667 42.666667 0 0 0-42.666666-42.666666h-213.333334a42.666667 42.666667 0 0 0 0 85.333333h109.653334l-139.946667 140.373333a42.666667 42.666667 0 0 0 0 60.586667 42.666667 42.666667 0 0 0 60.586667 0L768 316.586667V426.666667a42.666667 42.666667 0 0 0 42.666667 42.666666 42.666667 42.666667 0 0 0 42.666666-42.666666zM456.96 567.04a42.666667 42.666667 0 0 0-60.586667 0L256 706.986667V597.333333a42.666667 42.666667 0 0 0-42.666667-42.666666 42.666667 42.666667 0 0 0-42.666666 42.666666v213.333334a42.666667 42.666667 0 0 0 42.666666 42.666666h213.333334a42.666667 42.666667 0 0 0 0-85.333333H316.586667l140.373333-140.373333a42.666667 42.666667 0 0 0 0-60.586667z" /></svg>

After

Width:  |  Height:  |  Size: 929 B

View File

@ -16,6 +16,29 @@ function run() {
let chat_info_panel = document.getElementById("info-expand");
chat_info_panel.insertBefore(info_expand_button, chat_info_panel.childNodes[2]);
// move toggle-side-bar button
let chat_expand_button = document.getElementById("chat-expand-button");
let chat_column = document.getElementById("main-chat-bot");
let conv_column = document.getElementById("conv-settings-panel");
let default_conv_column_min_width = "min(300px, 100%)";
conv_column.style.minWidth = default_conv_column_min_width
globalThis.toggleChatColumn = (() => {
/* get flex-grow value of chat_column */
let flex_grow = conv_column.style.flexGrow;
console.log("chat col", flex_grow);
if (flex_grow == '0') {
conv_column.style.flexGrow = '1';
conv_column.style.minWidth = default_conv_column_min_width;
} else {
conv_column.style.flexGrow = '0';
conv_column.style.minWidth = "0px";
}
});
chat_column.insertBefore(chat_expand_button, chat_column.firstChild);
// move use mind-map checkbox
let mindmap_checkbox = document.getElementById("use-mindmap-checkbox");
let chat_setting_panel = document.getElementById("chat-settings-expand");

View File

@ -8,7 +8,7 @@ import gradio as gr
from ktem.app import BasePage
from ktem.components import reasonings
from ktem.db.models import Conversation, engine
from ktem.index.file.ui import File, chat_input_focus_js
from ktem.index.file.ui import File
from ktem.reasoning.prompt_optimization.suggest_conversation_name import (
SuggestConvNamePipeline,
)
@ -31,6 +31,12 @@ from .report import ReportIssue
DEFAULT_SETTING = "(default)"
INFO_PANEL_SCALES = {True: 8, False: 4}
chat_input_focus_js = """
function() {
let chatInput = document.querySelector("#chat-input textarea");
chatInput.focus();
}
"""
pdfview_js = """
function() {
@ -403,6 +409,9 @@ class ChatPage(BasePage):
inputs=self._info_panel_expanded,
outputs=[self.info_column, self._info_panel_expanded],
)
self.chat_control.btn_chat_expand.click(
fn=None, inputs=None, js="function() {toggleChatColumn();}"
)
self.chat_panel.chatbot.like(
fn=self.is_liked,

View File

@ -48,9 +48,17 @@ class ConversationControl(BasePage):
elem_classes=["no-background", "body-text-color"],
elem_id="toggle-dark-button",
)
self.btn_chat_expand = gr.Button(
value="",
icon=f"{ASSETS_DIR}/expand.svg",
scale=1,
size="sm",
elem_classes=["no-background", "body-text-color"],
elem_id="chat-expand-button",
)
self.btn_info_expand = gr.Button(
value="",
icon=f"{ASSETS_DIR}/sidebar.svg",
icon=f"{ASSETS_DIR}/expand.svg",
min_width=2,
scale=1,
size="sm",