From 85523c7f6baa572445f14fae6ab56f38be111714 Mon Sep 17 00:00:00 2001 From: Dita Aji Pratama Date: Thu, 18 Jun 2026 11:57:35 +0700 Subject: [PATCH 1/2] Output if session db have no model info --- tui/render.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tui/render.py b/tui/render.py index 622927b..ccc43d6 100644 --- a/tui/render.py +++ b/tui/render.py @@ -5,8 +5,6 @@ import curses import json import os -import textwrap -import config # -- Color pair IDs (id 1-9, id 0 = default curses) -- C_HEADER = 1 # header bar: biru @@ -90,21 +88,21 @@ def draw_chat(app, stdscr): rendered.append(segments) def _add_blank(): - rendered.append([(None, "")]) + rendered.append([(None, "", False)]) - def _wrap_render(text, indent=0, color=C_INPUT): + def _wrap_render(text, indent=0, color=C_INPUT, bold=False): available = w - indent - 1 # sisakan 1 kolom margin kanan if available <= 0: - _add_row([(color, " " * indent)]) + _add_row([(color, " " * indent, bold)]) return for line in text.split("\n"): if not line: - _add_row([(color, " " * indent)]) + _add_row([(color, " " * indent, bold)]) continue start = 0 while start < len(line): chunk = line[start:start + available] - _add_row([(color, " " * indent + chunk)]) + _add_row([(color, " " * indent + chunk, bold)]) start += available for idx, item in enumerate(app.log): @@ -130,21 +128,20 @@ def draw_chat(app, stdscr): model_info = item.get("model_info", None) if model_info: p_name, m_name = model_info + if p_name: + info_line = f" {p_name} - {m_name} " + else: + info_line = f" {m_name} " else: - p_name = config.resolve_provider(app.llm.base_url, app.llm.model) - m_name = app.llm.model - if p_name: - info_line = f" {p_name} - {m_name} " - else: - info_line = f" {m_name} " - _add_row([(C_USER, info_line)]) + info_line = " Unknown - Model info not found " + _add_row([(C_USER, info_line, False)]) label = f" You ({item['time']}) " _add_row([(C_USER, label)]) - _wrap_render(text, indent=1, color=C_INPUT) + _wrap_render(text, indent=1, color=C_INPUT, bold=False) elif role == "ai": label = f" Hendrik ({item['time']}) " _add_row([(C_AI, label)]) - _wrap_render(text, indent=1, color=C_INPUT) + _wrap_render(text, indent=1, color=C_INPUT, bold=False) elif role == "system": lines = text.split("\n") _add_row([(C_SYSTEM, lines[0])]) @@ -218,10 +215,11 @@ def draw_chat(app, stdscr): for i in range(app.scroll, min(app.scroll + chat_h, total)): segments = rendered[i] x = 0 - for color, text in segments: + for color, text, *bold_flag in segments: if not text: continue - attr = curses.color_pair(color) | curses.A_BOLD if color else curses.A_NORMAL + is_bold = bold_flag[0] if bold_flag else True + attr = curses.color_pair(color) | (curses.A_BOLD if is_bold else 0) if color else curses.A_NORMAL remaining = w - x if remaining <= 0: break From 2c82f972bf4fa0c9b6ab8b9895033e496af5ea7e Mon Sep 17 00:00:00 2001 From: Dita Aji Pratama Date: Thu, 18 Jun 2026 14:02:11 +0700 Subject: [PATCH 2/2] Fixing UI bug for a new session --- tui/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tui/app.py b/tui/app.py index 24467b9..f44510b 100644 --- a/tui/app.py +++ b/tui/app.py @@ -51,8 +51,7 @@ class HendrikTUI: } def new_session(self): - name = f"Session {datetime.now().strftime('%Y-%m-%d %H:%M')}" - self.current_session = self.session_mgr.create(name, self._model_info()) + self.current_session = None self.messages = [{"role": "system", "content": self.build_system_prompt( tools_definition=self.tools_def, character=config.AGENT_CHARACTER or None, @@ -60,6 +59,9 @@ class HendrikTUI: )}] self.log.clear() self.scroll = 0 + self.input_buffer = [""] + self.input_line = 0 + self.input_col = 0 log(self, "welcome", WELCOME_ART) def switch_session(self, doc_id: int):