AnatoliiG commited on
Commit
ca9762f
·
1 Parent(s): e7d8d34

infinite bug

Browse files
Files changed (2) hide show
  1. src/ui/components.py +7 -5
  2. src/ui/styles.py +6 -30
src/ui/components.py CHANGED
@@ -6,13 +6,13 @@ from src.ui.styles import CSS
6
 
7
 
8
  def create_ui():
9
- # fill_height=True заставит приложение занять весь экран по высоте
10
- with gr.Blocks(theme=gr.themes.Soft(), css=CSS, fill_height=True) as demo:
11
  gr.HTML(f"<style>{CSS}</style>")
12
  gr.HTML("<script>document.title = 'Code LLM Agent';</script>")
13
 
14
  with gr.Row(elem_id="main-row", variant="panel"):
15
- # Задаем ширину сайдбара через Python, чтобы Gradio корректно рассчитывал его скрытие
16
  with gr.Sidebar(elem_id="sidebar-container", width=280):
17
  gr.Markdown("## 🛠️ Dashboard")
18
 
@@ -48,8 +48,10 @@ def create_ui():
48
 
49
  # Основная область чата
50
  with gr.Column(elem_id="col-chat-main"):
51
- # Безопасное создание чат-бота без конфликтующих аргументов
52
- chatbot = gr.Chatbot(elem_id="chatbot", show_label=False)
 
 
53
 
54
  with gr.Row(elem_id="input-area"):
55
  msg = gr.Textbox(
 
6
 
7
 
8
  def create_ui():
9
+ # Базовые блоки без конфликтующих флагов высоты
10
+ with gr.Blocks(theme=gr.themes.Soft(), css=CSS) as demo:
11
  gr.HTML(f"<style>{CSS}</style>")
12
  gr.HTML("<script>document.title = 'Code LLM Agent';</script>")
13
 
14
  with gr.Row(elem_id="main-row", variant="panel"):
15
+ # Боковая панель
16
  with gr.Sidebar(elem_id="sidebar-container", width=280):
17
  gr.Markdown("## 🛠️ Dashboard")
18
 
 
48
 
49
  # Основная область чата
50
  with gr.Column(elem_id="col-chat-main"):
51
+ # Нативно задаем высоту чата в Python — это защищает от циклов рендеринга
52
+ chatbot = gr.Chatbot(
53
+ elem_id="chatbot", show_label=False, height="calc(100vh - 180px)"
54
+ )
55
 
56
  with gr.Row(elem_id="input-area"):
57
  msg = gr.Textbox(
src/ui/styles.py CHANGED
@@ -1,24 +1,16 @@
1
  CSS = """
2
- /* 1. Блокировка высоты и скролла всей страницы (как в ChatGPT) */
3
  html, body, .gradio-container {
4
  background-color: #212121 !important;
5
  margin: 0 !important;
6
  padding: 0 !important;
7
- height: 100vh !important;
8
- min-height: 100vh !important;
9
- max-height: 100vh !important;
10
- overflow: hidden !important; /* Убирает бесконечный скролл страницы */
11
  }
12
 
13
- /* 2. Главный ряд на всю высоту экрана */
14
  #main-row {
15
  margin: 0 !important;
16
  gap: 0 !important;
17
  background-color: #212121 !important;
18
- height: 100vh !important;
19
- min-height: 100vh !important;
20
- max-height: 100vh !important;
21
- overflow: hidden !important;
22
  }
23
 
24
  /* 3. Боковая панель */
@@ -26,11 +18,9 @@ html, body, .gradio-container {
26
  background-color: #171717 !important;
27
  border-right: 1px solid #2f2f2f !important;
28
  padding: 1.5rem 1.25rem !important;
29
- height: 100vh !important;
30
- overflow-y: auto !important;
31
  }
32
 
33
- /* Кнопка сворачивания/разворачивания сайдбара */
34
  .sidebar-parent button.toggle-button,
35
  .sidebar-parent > button {
36
  background-color: #171717 !important;
@@ -52,20 +42,14 @@ html, body, .gradio-container {
52
  background-color: #2f2f2f !important;
53
  }
54
 
55
- /* 4. Колонка чата (принудительно прижимает ввод вниз) */
56
  #col-chat-main {
57
  background-color: #212121 !important;
58
  padding: 0 !important;
59
  margin: 0 !important;
60
- height: 100vh !important;
61
- max-height: 100vh !important;
62
- display: flex !important;
63
- flex-direction: column !important;
64
- justify-content: space-between !important; /* Чат сверху, ввод строго снизу */
65
- overflow: hidden !important;
66
  }
67
 
68
- /* Область сообщений занимает все свободное пространство */
69
  #chatbot {
70
  background-color: transparent !important;
71
  border: none !important;
@@ -73,17 +57,11 @@ html, body, .gradio-container {
73
  max-width: 800px !important;
74
  margin: 0 auto !important;
75
  width: 100% !important;
76
- flex: 1 1 auto !important; /* Растягивается на максимум */
77
- min-height: 0 !important; /* Предотвращает раздувание */
78
- overflow-y: auto !important; /* Скролл только внутри чата */
79
  }
80
 
81
  #chatbot > .wrapper {
82
  background: transparent !important;
83
  border: none !important;
84
- display: flex !important;
85
- flex-direction: column !important;
86
- height: 100% !important;
87
  }
88
 
89
  /* 5. Настройки пузырей сообщений и текста */
@@ -128,15 +106,13 @@ html, body, .gradio-container {
128
  color: #ececec !important;
129
  }
130
 
131
- /* 6. Поле ввода прижатое к низу */
132
  #input-area {
133
  max-width: 800px !important;
134
- width: 100% !important;
135
  margin: 0 auto 1.5rem auto !important;
136
  padding: 0 1rem !important;
137
  background: transparent !important;
138
  border: none !important;
139
- flex-shrink: 0 !important; /* Не позволяет сжимать поле ввода */
140
  }
141
 
142
  #input-area > div,
 
1
  CSS = """
2
+ /* 1. Глобальный фон страницы */
3
  html, body, .gradio-container {
4
  background-color: #212121 !important;
5
  margin: 0 !important;
6
  padding: 0 !important;
 
 
 
 
7
  }
8
 
9
+ /* 2. Главный ряд */
10
  #main-row {
11
  margin: 0 !important;
12
  gap: 0 !important;
13
  background-color: #212121 !important;
 
 
 
 
14
  }
15
 
16
  /* 3. Боковая панель */
 
18
  background-color: #171717 !important;
19
  border-right: 1px solid #2f2f2f !important;
20
  padding: 1.5rem 1.25rem !important;
 
 
21
  }
22
 
23
+ /* Кнопка сворачивания/разворачивания сайдбара (круглая, всегда поверх) */
24
  .sidebar-parent button.toggle-button,
25
  .sidebar-parent > button {
26
  background-color: #171717 !important;
 
42
  background-color: #2f2f2f !important;
43
  }
44
 
45
+ /* 4. Колонка чата */
46
  #col-chat-main {
47
  background-color: #212121 !important;
48
  padding: 0 !important;
49
  margin: 0 !important;
 
 
 
 
 
 
50
  }
51
 
52
+ /* Стилизация компонента Chatbot */
53
  #chatbot {
54
  background-color: transparent !important;
55
  border: none !important;
 
57
  max-width: 800px !important;
58
  margin: 0 auto !important;
59
  width: 100% !important;
 
 
 
60
  }
61
 
62
  #chatbot > .wrapper {
63
  background: transparent !important;
64
  border: none !important;
 
 
 
65
  }
66
 
67
  /* 5. Настройки пузырей сообщений и текста */
 
106
  color: #ececec !important;
107
  }
108
 
109
+ /* 6. Поле ввода (ChatGPT стиль) */
110
  #input-area {
111
  max-width: 800px !important;
 
112
  margin: 0 auto 1.5rem auto !important;
113
  padding: 0 1rem !important;
114
  background: transparent !important;
115
  border: none !important;
 
116
  }
117
 
118
  #input-area > div,