Fixing minor issues

This commit is contained in:
Dita Aji Pratama 2026-06-17 16:41:41 +07:00
parent b954f5a6cb
commit 34527d5438
3 changed files with 20 additions and 8 deletions

View File

@ -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(

View File

@ -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()

View File

@ -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)