splinter: the chat says who is speaking, scrolling works, child stderr stays inside

[19:20:25] <lotherk> was ist ein semaphor? ein satz
  [19:20:35] * Qwen3.6-35B-A3B-UD-Q8_K_XL is thinking: The user is asking in German
  [19:20:38] <Qwen3.6-35B-A3B-UD-Q8_K_XL> Ein Semaphore ist eine Datenstruktur

The name comes from the environment and the configuration, not from a role label:
'<you>' was a literal, 'thinking is thinking' was a label talking about itself.

PgDn moved the scroll counter and never repainted - the screen agreed with
nothing. PgUp/PgDn now scroll ten lines, Shift+Up/Down one, and both repaint.

A tool's stderr went to the terminal and landed in the middle of the curses
screen. It is captured into the answer now ('{ cmd\n} 2>&1'), where the model can
read it and the UI stays intact.

Delegates for this machine (drop-in, keys by name only):
  kontron 5  local 35B        ocgo 10   opencode-go deepseek-v4.1-flash
  ollama 8   cloud same model claudecli 9  claude -p
  occli 9    opencode run --model big-pickle
A cli delegate no longer needs endpoint and model: claude and opencode bring
their own. The wrapper loads ~/.hermes/.env so keys are read, never copied.
This commit is contained in:
Konrad committed 2026-11-08 19:21:11 +00:00
1 parent 3c5cdaf53a
commit 5595352389
6 files changed
+99 -20

No files matched your search

+15 -1
View File
@@ -87,7 +87,21 @@ tool_run(const char *args, struct sp_buf *out, void *ctx)
sp_buf_free(&keep);
return sp_buf_puts(out, "error: empty command");
}
p = popen(cmd, "r");
/*
* stderr of the child belongs in the answer, not on the terminal: a curses
* screen that suddenly contains a shell error is broken, and the error is
* exactly what the model needs to see.
*/
{
struct sp_buf wrapped = { 0 };
if (sp_buf_init(&wrapped) == 0 &&
sp_buf_printf(&wrapped, "{ %s\n} 2>&1", cmd) == 0) {
p = popen(wrapped.p, "r");
sp_buf_free(&wrapped);
} else
p = popen(cmd, "r");
}
if (p == NULL) {
rc = sp_buf_printf(out, "error: popen: %s", strerror(errno));
sp_buf_free(&keep);
+7 -1
View File
@@ -212,7 +212,13 @@ parse_delegate(struct sp_delegate *d, const char *val, struct sp_buf *err,
path, lineno);
return -1;
}
if (d->endpoint[0] == '\0' || d->model[0] == '\0') {
/*
* A cli delegate runs a program, not an endpoint: claude and opencode bring
* their own model choice. Requiring endpoint and model there would force a
* fake value into the file, which is worse than no value.
*/
if (strcmp(d->kind, "cli") != 0 &&
(d->endpoint[0] == '\0' || d->model[0] == '\0')) {
sp_buf_printf(err, "config: %s:%u: delegate '%s' needs endpoint "
"and model", path, lineno, d->id);
return -1;
+1 -1
View File
@@ -775,7 +775,7 @@ main(int argc, char **argv)
fprintf(stderr, "splinter: kein Profil fuer '%s' - "
"`splinter --interview` legt eins an\n",
sp_memory_user());
rc = sp_ui_run(&ag, endpoint, theme, host);
rc = sp_ui_run(&ag, endpoint, model, theme, host);
if (have_mock)
sp_mock_free(&mock);
sp_host_free(host);
+75 -16
View File
@@ -44,6 +44,13 @@
/* set while a turn runs: widgets hold still instead of ticking under the answer */
static volatile int g_turn_busy;
/*
* Who is speaking. Not the role - the name: the person from $USER, the model from
* the configuration. 'thinking is thinking' was a label talking about itself.
*/
static char g_who[128] = "you";
static char g_model[128] = "model";
#define MAX_ENTRIES 512
struct entry {
@@ -521,15 +528,37 @@ static void
entry_prefix(const struct entry *e, char *buf, size_t len)
{
struct tm tm;
char clock[16];
char clock[16], who[64];
(void)localtime_r(&e->ts, &tm);
strftime(clock, sizeof(clock), "%H:%M:%S", &tm);
if (strcmp(e->role, "thinking") == 0)
snprintf(buf, len, "[%s] * %s is thinking ", clock,
role_label(e->role));
else
snprintf(buf, len, "[%s] <%s> ", clock, role_label(e->role));
if (strcmp(e->role, "thinking") == 0) {
snprintf(who, sizeof(who), "%.40s", g_model);
{
char *dot = strstr(who, ".gguf");
if (dot != NULL)
*dot = '\0';
}
snprintf(buf, len, "[%s] * %s is thinking: ", clock, who);
} else if (strcmp(e->role, "you") == 0) {
snprintf(who, sizeof(who), "%.40s", g_who);
snprintf(buf, len, "[%s] <%s> ", clock, who);
} else if (strcmp(e->role, "agent") == 0) {
snprintf(who, sizeof(who), "%.40s", g_model);
{
char *dot = strstr(who, ".gguf");
if (dot != NULL)
*dot = '\0';
}
snprintf(buf, len, "[%s] <%s> ", clock, who);
} else if (strcmp(e->role, "splinter") == 0) {
snprintf(buf, len, "[%s] --- ", clock);
} else {
snprintf(who, sizeof(who), "%.40s", role_label(e->role));
snprintf(buf, len, "[%s] <%s> ", clock, who);
}
}
static int
@@ -541,7 +570,7 @@ entry_lines(int cols, const struct entry *e)
if (cols < 2)
return 1;
{
char prefix[128];
char prefix[256];
entry_prefix(e, prefix, sizeof(prefix));
len = strlen(prefix) + strlen(e->text) + 1;
@@ -956,8 +985,8 @@ layout(void)
}
int
sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *theme_name,
struct sp_host *host)
sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *model,
const char *theme_name, struct sp_host *host)
{
struct ui_state s;
struct sp_buf answer = { 0 }, err = { 0 };
@@ -968,6 +997,23 @@ sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *theme_name,
memset(&s, 0, sizeof(s));
sp_buf_init(&s.last_think);
s.endpoint = endpoint;
{
const char *user = getenv("USER");
const char *slash;
size_t n;
if (user != NULL && *user != '\0')
snprintf(g_who, sizeof(g_who), "%s", user);
if (model != NULL && *model != '\0') {
/* a path like /models/x/y.gguf: the name is the last part */
slash = strrchr(model, '/');
snprintf(g_model, sizeof(g_model), "%s",
slash != NULL ? slash + 1 : model);
n = strlen(g_model);
if (n > 4 && strcmp(g_model + n - 4, ".gguf") == 0)
g_model[n - 4] = '\0';
}
}
g_status_host = host; /* the status line is drawn per tick */
if (sp_buf_init(&answer) != 0 || sp_buf_init(&err) != 0)
return 1;
@@ -1463,8 +1509,14 @@ sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *theme_name,
wrefresh(ui_input);
continue;
}
if (c == KEY_PPAGE) {
s.scroll += 3;
/*
* PgUp/PgDn and Shift+Up/Down scroll the
* conversation. The earlier PgDn moved a counter
* and never repainted, so the screen agreed with
* nothing.
*/
if (c == KEY_PPAGE || c == KEY_SR) {
s.scroll += (c == KEY_SR ? 1 : 10);
draw_history(&s, 0);
draw_sidebar(&s, ag->sess != NULL ?
ag->sess->id : NULL,
@@ -1474,11 +1526,18 @@ sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *theme_name,
doupdate();
continue;
}
if (c == KEY_NPAGE) {
if (s.scroll > 3)
s.scroll = s.scroll >= 3 ? s.scroll - 3 : 0;
else
s.scroll = 0;
if (c == KEY_NPAGE || c == KEY_SF) {
int step = (c == KEY_SF ? 1 : 10);
s.scroll = s.scroll > (size_t)step ?
s.scroll - (size_t)step : 0;
draw_history(&s, 0);
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 == 3) {
+1 -1
View File
@@ -10,7 +10,7 @@
* palette name; NULL selects the default. `host` may be NULL (no plugins).
* Returns 0 on a clean quit.
*/
int sp_ui_run(struct sp_agent *ag, const char *endpoint,
int sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *model,
const char *theme_name, struct sp_host *host);
/*
BIN
View File
Binary file not shown.