diff --git a/src/frontend/curses.c b/src/frontend/curses.c index 2fecac2..dba257c 100644 --- a/src/frontend/curses.c +++ b/src/frontend/curses.c @@ -2405,7 +2405,15 @@ draw_prompt(struct ui_state *s, const char *input) * second copy of the same 120 lines for /sessions would have meant two places * that handle Esc, resize and the filter differently. What differs is the * title, the two "nothing here" lines and what Enter does with the choice. + * + * How many rows it holds is not SP_MODEL_CHOICES: that is /model's cap, while + * the session side fills the same struct with up to 100 rows (FOREIGN_ROW_MAX + * and sp_session_list's 100). With the smaller cap the source line said + * "claude (100)" and the last four rows could not be reached - pick_add + * dropped them without a word. */ +#define SP_PICK_ROWS 128 + struct pick_item { char sel[320]; /* what Enter hands back */ char label[512]; /* what the row shows */ @@ -2413,7 +2421,7 @@ struct pick_item { }; struct pick_list { - struct pick_item v[SP_MODEL_CHOICES]; + struct pick_item v[SP_PICK_ROWS]; size_t n; }; @@ -2430,7 +2438,7 @@ pick_add(void *ctx, const char *sel, const char *label, int current) { struct pick_list *l = ctx; - if (l->n >= SP_MODEL_CHOICES || sel == NULL) + if (l->n >= SP_PICK_ROWS || sel == NULL) return; snprintf(l->v[l->n].sel, sizeof(l->v[l->n].sel), "%s", sel); snprintf(l->v[l->n].label, sizeof(l->v[l->n].label), "%s", @@ -2609,7 +2617,7 @@ pick_run(struct pick_view *view, struct pick_list *list, void *pendingctx, char *sel, size_t cap) { char filter[64]; - size_t flen = 0, match[SP_MODEL_CHOICES], nmatch; + size_t flen = 0, match[SP_PICK_ROWS], nmatch; size_t cur = 0, top = 0; WINDOW *win; int w, h, rc = -1, c; diff --git a/tests/test_ui.sh b/tests/test_ui.sh index 4b40b78..bf26b64 100755 --- a/tests/test_ui.sh +++ b/tests/test_ui.sh @@ -278,5 +278,32 @@ sleep 1 check not_shows 'ready. Enter sends' # and PgDn leaves it again check test "$(quit_code)" = 0 +# ---- the picker holds every row the backend lists ---- +# The session side can answer with 100 rows (sp_session_list's cap). The picker +# used to size its list with SP_MODEL_CHOICES (96, /model's cap), so a source +# that said "100" had four rows nobody could reach - pick_add dropped them +# silently. 99 files plus this run's own session is exactly 100, and the one +# with the oldest mtime sorts last: it is the row the cap would have cut. +start 4 +typed 'single word ok'; key Enter +check shows ' ok' +for i in $(seq 1 99); do + printf '{"role":"user","text":"session %s"}\n' "$i" \ + > "$D/home/.splinter/sess-17940000$(printf %02d "$i")-1-1.jsonl" +done +printf '{"role":"user","text":"die aelteste zeile"}\n' \ + > "$D/home/.splinter/sess-1795000001-1-1.jsonl" +touch -t 202001010000 "$D/home/.splinter/sess-1795000001-1-1.jsonl" +typed '/sessions'; key Enter +check shows 'splinter (' +key Enter +check shows 'Enter opens the session' +# the id is the selector, so filtering by it reaches exactly that row +typed '1795000001' +check shows 'sess-1795000001-1-1' +key Escape; sleep 0.3; key Escape +sleep 0.5 +check test "$(quit_code)" = 0 + if [ "$fails" -eq 0 ]; then echo "test_ui: ok"; exit 0; fi exit 1