Three bugs in the /sessions picker, all of them found by review and all of
them visible on the screen:
- sp_engine_sources() hard-set every foreign source's count to 0, so the
picker offered "claude (0)" while 82 rows were behind it. The count now
comes from the same listing the picker shows.
- sp_foreign_sessions() hard-set each row's date to 0, so every foreign
session drew as 1970-01-01. The plugin prints "%Y-%m-%d %H:%M" and the
row's first column is parsed into epoch seconds.
- The foreign plugin's list tool queried with its configured default
(limit = 25) no matter what the caller asked for, so asking for 100 rows
returned 25 and a store with 290 sessions looked like one with 25. The
caller's limit now reaches the SQL.
Proof: tests/test_foreignopen.c asserts count == 1 and mtime > 1600000000
against a fixture store; reverting either fix makes both checks fail. Live
over the socket, before: [('splinter', 100), ('claude', 0), ('opencode', 0)]
with mtime 0 on every row; after: [('splinter', 100), ('claude', 82),
('opencode', 100)] with mtime 1795387200. sqlite3 counts 290 opencode
sessions and 82 claude files, so the numbers agree with the stores.
make check: 21 suites, 0 failures. check_i18n: 229 keys in 3 catalogues.
The operator's claude ran into its limit mid-work; the session was too full to
continue there. The foreign plugin could already read and import it, but only
through a tool call inside a turn - there was no way in from the command line.
--claude, --opencode, --hermes and --from=NAME make the newest session that
tool ran in this directory the session of the run: it is imported before the
history is loaded, so the first turn already carries it. -c no longer fails in
a folder that has no splinter session yet; it falls back to "no session" and
lets the import decide. An empty placeholder session is removed again, whether
the import worked or not.
Repeating the call continues the same session instead of importing a second
time: sp_session_foreign() reads the foreign= marker back, so the work done in
splinter is kept. A second foreign_import into the same session replaces the
history rather than appending it twice (path_join built "id/.jsonl", so the
replace branch never fired).
Test: tests/test_foreignopen.c builds a claude fixture under its own HOME and
covers import, idempotency, replace-not-append, the empty placeholder and a
folder with no foreign session. make check exit 0, check_asan.sh clean.