From 34527d54384725e6528ab72775fce65406d5c872 Mon Sep 17 00:00:00 2001 From: Dita Aji Pratama Date: Wed, 17 Jun 2026 16:41:41 +0700 Subject: [PATCH] Fixing minor issues --- tui/agent.py | 8 +++++++- tui/app.py | 18 ++++++++++++------ tui/render.py | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tui/agent.py b/tui/agent.py index 79772dd..763a735 100644 --- a/tui/agent.py +++ b/tui/agent.py @@ -62,7 +62,13 @@ def submit(app, stdscr): app.scroll = 999999 app.processing = True - _add_msg(app, "user", query) + if app.current_session is None: + app.current_session = app.session_mgr.create( + f"Session {datetime.now().strftime('%Y-%m-%d %H:%M')}", + app._model_info(), + ) + + _add_msg(app, "user", query, model_info=app._model_info()) app.agent_done.clear() app.agent_thread = threading.Thread( diff --git a/tui/app.py b/tui/app.py index 97aa8c2..807a681 100644 --- a/tui/app.py +++ b/tui/app.py @@ -71,15 +71,16 @@ class HendrikTUI: self.log.clear() self.scroll = 0 log(self, "welcome", WELCOME_ART) - for msg in session.messages: + for i, msg in enumerate(session.messages): if msg["role"] == "user": + if i > 0: + log(self, "sep", "") log(self, "user", msg["content"]) + mi = msg.get("model_info") + if mi: + self.log[-1]["model_info"] = (mi.get("provider"), mi.get("model")) elif msg["role"] == "assistant": log(self, "ai", msg["content"]) - elif msg["role"] == "system" and msg.get("content"): - if len(msg["content"]) > 100: - continue - log(self, "system", msg["content"]) def run(self): try: @@ -93,7 +94,12 @@ class HendrikTUI: stdscr.keypad(True) stdscr.refresh() - self.new_session() + self.messages = [{"role": "system", "content": self.build_system_prompt( + tools_definition=self.tools_def, + character=config.AGENT_CHARACTER or None, + skills=config.AGENT_SKILLS.split(",") if config.AGENT_SKILLS else None, + )}] + log(self, "welcome", WELCOME_ART) while self.running: self.h, self.w = stdscr.getmaxyx() diff --git a/tui/render.py b/tui/render.py index a7640cf..622927b 100644 --- a/tui/render.py +++ b/tui/render.py @@ -137,7 +137,7 @@ def draw_chat(app, stdscr): info_line = f" {p_name} - {m_name} " else: info_line = f" {m_name} " - _add_row([(C_SYSTEM, info_line)]) + _add_row([(C_USER, info_line)]) label = f" You ({item['time']}) " _add_row([(C_USER, label)]) _wrap_render(text, indent=1, color=C_INPUT)