mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-22 00:06:21 +00:00
ref(ai): move unfitting functions out of window.c; create aiwin.c
This commit is contained in:
@@ -347,16 +347,7 @@ win_create_ai(AISession* session)
|
||||
return &new_win->window;
|
||||
}
|
||||
|
||||
void
|
||||
win_ai_free(ProfAiWin* win)
|
||||
{
|
||||
assert(win->memcheck == PROFAIWIN_MEMCHECK);
|
||||
buffer_free(win->message_buffer);
|
||||
g_string_free(win->conversation_history, TRUE);
|
||||
if (win->session) {
|
||||
ai_session_unref(win->session);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gchar*
|
||||
win_get_title(ProfWin* window)
|
||||
@@ -2424,45 +2415,3 @@ get_enc_char(prof_enc_t enc_mode, const char* alt)
|
||||
else
|
||||
return get_show_char(enc_mode);
|
||||
}
|
||||
|
||||
// AI Window Functions
|
||||
|
||||
char*
|
||||
aiwin_get_string(ProfAiWin* win)
|
||||
{
|
||||
assert(win->memcheck == PROFAIWIN_MEMCHECK);
|
||||
return g_strdup_printf("AI Chat (%s: %s)", win->session->provider_name, win->session->model);
|
||||
}
|
||||
|
||||
void
|
||||
aiwin_display_response(ProfAiWin* win, const char* response)
|
||||
{
|
||||
log_debug("[AI-WIN] aiwin_display_response ENTER: win=%p, response='%s'", (void*)win, response);
|
||||
assert(win->memcheck == PROFAIWIN_MEMCHECK);
|
||||
|
||||
if (!response) {
|
||||
log_error("[AI-WIN] FAIL: null response");
|
||||
return;
|
||||
}
|
||||
|
||||
// Display AI response
|
||||
win_println(&win->window, THEME_DEFAULT, "<< LLM:", "%s", response);
|
||||
log_debug("[AI-WIN] Displayed AI response");
|
||||
|
||||
// Add to conversation history
|
||||
ai_session_add_message(win->session, "assistant", response);
|
||||
log_debug("[AI-WIN] Added assistant message to session history");
|
||||
}
|
||||
|
||||
void
|
||||
aiwin_display_error(ProfAiWin* win, const char* error_msg)
|
||||
{
|
||||
log_debug("[AI-WIN] aiwin_display_error ENTER: win=%p, error='%s'", (void*)win, error_msg);
|
||||
assert(win->memcheck == PROFAIWIN_MEMCHECK);
|
||||
|
||||
const char* msg = error_msg ? error_msg : "Unknown error";
|
||||
win_println(&win->window, THEME_ERROR, "[ERROR]", "%s", msg);
|
||||
|
||||
// Also show error in console so user sees it regardless of active window
|
||||
cons_show_error("AI Error: %s", msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user