splinter: the reasoning gets its own field in the sidebar
A reasoning model spends a minute thinking before it prints a word. That text was hidden, so a long turn looked like a dead terminal. It now has its own area in the sidebar: wrapped to the width, bottom-anchored like a log, scrollable with PgUp/PgDn while it streams, and kept after the turn so you can read what led to an answer. Next to it the sidebar counts what the turn produced (characters and an approximate token count, marked as approximate because the server only reports the real number at the end). Measured against kontron (Qwen3.6-35B): at 12 s the field was still empty (prefill), at 37 s it held the plan in English while the answer came in German - the model plans in one language and answers in another, which is worth being able to see. Also: the thinking field renders through the same ASCII transliteration as the rest of the UI, so the vendored curses defect does not come back in the one place that shows the most text.
This commit is contained in:
1 parent
5c07b32478
commit
4ce25255a7
1 file changed
+89
@@ -46,6 +46,9 @@ struct ui_state {
|
||||
size_t n;
|
||||
size_t scroll; /* lines scrolled back from the bottom */
|
||||
long last_ms;
|
||||
size_t out_chars; /* characters streamed in this/last turn */
|
||||
size_t think_back; /* lines scrolled back in the thinking field */
|
||||
struct sp_buf last_think; /* the previous turn's reasoning */
|
||||
size_t last_steps;
|
||||
size_t last_calls;
|
||||
const char *endpoint;
|
||||
@@ -360,6 +363,51 @@ draw_live(struct ui_state *s, const char *text, const char *tool,
|
||||
wnoutrefresh(ui_hist);
|
||||
}
|
||||
|
||||
/*
|
||||
* The reasoning gets its own area: wrapped to the sidebar width, bottom-
|
||||
* anchored like a log, and scrollable with PgUp/PgDn while it streams. It is
|
||||
* not squeezed into one line, because a model's planning is exactly the thing
|
||||
* you want to read when a turn takes a minute.
|
||||
*/
|
||||
static void
|
||||
draw_think_field(int y0, int rows, int cols, const char *text, size_t back)
|
||||
{
|
||||
size_t len, lines, first, i;
|
||||
int y;
|
||||
|
||||
if (text == NULL || text[0] == '\0' || rows < 2 || cols < 4)
|
||||
return;
|
||||
len = strlen(text);
|
||||
lines = (len + (size_t)cols - 1) / (size_t)cols;
|
||||
if (lines == 0)
|
||||
return;
|
||||
first = lines > (size_t)rows ? lines - (size_t)rows : 0;
|
||||
if (back > 0) {
|
||||
if (back > first)
|
||||
back = first;
|
||||
first -= back;
|
||||
}
|
||||
wattron(ui_side, COLOR_PAIR(PAIR_DIM));
|
||||
for (y = 0, i = first; y < rows && i < lines; y++, i++) {
|
||||
size_t off = i * (size_t)cols;
|
||||
size_t take = len - off;
|
||||
|
||||
if (take > (size_t)cols)
|
||||
take = (size_t)cols;
|
||||
wmove(ui_side, y0 + y, 0);
|
||||
{
|
||||
char slice[256];
|
||||
|
||||
if (take >= sizeof(slice))
|
||||
take = sizeof(slice) - 1;
|
||||
memcpy(slice, text + off, take);
|
||||
slice[take] = '\0';
|
||||
ui_add_text(ui_side, slice, (int)take);
|
||||
}
|
||||
}
|
||||
wattroff(ui_side, COLOR_PAIR(PAIR_DIM));
|
||||
}
|
||||
|
||||
static void
|
||||
sidebar_heading(int *y, int cols, const char *text)
|
||||
{
|
||||
@@ -402,6 +450,11 @@ draw_sidebar(struct ui_state *s, const char *id, const char *dir,
|
||||
mvwprintw(ui_side, y++, 0, "%zu tool calls", s->last_calls);
|
||||
y++;
|
||||
|
||||
sidebar_heading(&y, cols, "output");
|
||||
mvwprintw(ui_side, y++, 0, "%zu chars (~%zu tok)",
|
||||
s->out_chars, s->out_chars / 4);
|
||||
y++;
|
||||
|
||||
sidebar_heading(&y, cols, "widgets");
|
||||
if (host == NULL || sp_host_widget_count(host) == 0) {
|
||||
wattron(ui_side, COLOR_PAIR(PAIR_DIM));
|
||||
@@ -419,6 +472,16 @@ draw_sidebar(struct ui_state *s, const char *id, const char *dir,
|
||||
}
|
||||
}
|
||||
wattrset(ui_side, A_NORMAL);
|
||||
|
||||
if (s->last_think.p != NULL && s->last_think.len > 0 &&
|
||||
y + 3 < getmaxy(ui_side)) {
|
||||
int avail;
|
||||
|
||||
y++;
|
||||
sidebar_heading(&y, cols, "thinking (PgUp/PgDn)");
|
||||
avail = getmaxy(ui_side) - y;
|
||||
draw_think_field(y, avail, cols, s->last_think.p, s->think_back);
|
||||
}
|
||||
wnoutrefresh(ui_side);
|
||||
}
|
||||
|
||||
@@ -488,6 +551,7 @@ sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *theme_name,
|
||||
int rc = 0;
|
||||
|
||||
memset(&s, 0, sizeof(s));
|
||||
sp_buf_init(&s.last_think);
|
||||
s.endpoint = endpoint;
|
||||
if (sp_buf_init(&answer) != 0 || sp_buf_init(&err) != 0)
|
||||
return 1;
|
||||
@@ -671,6 +735,12 @@ sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *theme_name,
|
||||
pthread_mutex_unlock(&tu.lock);
|
||||
live[llen2] = '\0';
|
||||
think[tlen2] = '\0';
|
||||
if (tlen2 > 0) {
|
||||
sp_buf_clear(&s.last_think);
|
||||
(void)sp_buf_puts(&s.last_think,
|
||||
think);
|
||||
}
|
||||
s.out_chars = llen2;
|
||||
draw_history(&s);
|
||||
draw_live(&s, live, tool, think);
|
||||
doupdate();
|
||||
@@ -687,6 +757,24 @@ sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *theme_name,
|
||||
wrefresh(ui_input);
|
||||
continue;
|
||||
}
|
||||
if (c == KEY_PPAGE) {
|
||||
s.think_back += 3;
|
||||
draw_history(&s);
|
||||
draw_sidebar(&s, ag->sess != NULL ?
|
||||
ag->sess->id : NULL,
|
||||
ag->sess != NULL ? ag->sess->dir :
|
||||
NULL, host);
|
||||
draw_status(&s);
|
||||
doupdate();
|
||||
continue;
|
||||
}
|
||||
if (c == KEY_NPAGE) {
|
||||
if (s.think_back > 3)
|
||||
s.think_back -= 3;
|
||||
else
|
||||
s.think_back = 0;
|
||||
continue;
|
||||
}
|
||||
if (c == 3) {
|
||||
tu.cancel = 1;
|
||||
cancelled = 1;
|
||||
@@ -795,6 +883,7 @@ sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *theme_name,
|
||||
}
|
||||
|
||||
endwin();
|
||||
sp_buf_free(&s.last_think);
|
||||
sp_buf_free(&answer);
|
||||
sp_buf_free(&err);
|
||||
return rc;
|
||||
|
||||
Reference in new issue
Block a user