ZCode files a fork as sess_<id> with its parent's id in parent_id
(task_type=fork), and ocRoots groups it under the parent's key. A
request names the fork by its own id, but Titles only looked up
sess_subagent_agent_<id> children, so a fork's Routing card fell back
to the folder name though its row has a title of its own.
The child index in Titles now holds every ZCode session with a parent,
by its sid and its bare id (zcodeBareID), so a fork is named from its
own file the way a subagent is. A top-level session is still named by
its own group only. The parent's title is unchanged.
Changed from the patch: the index holds child sessions only (the patch
indexed every ZCode session, so a top-level session's empty group title
could be filled from the cache fallback), and the "session_" prefix the
patch also stripped is dropped, since no ZCode id has it.
Run (mote, sandbox HOME via the package's TestMain):
- go test -tags nogui -run 'TestZCode|TestSessionTitles' ./internal/sessions/: ok.
- go test -tags nogui ./internal/sessions/: ok (20.7s).
- go test -tags nogui -run TestSessionTitlesNameOtherAgents ./internal/gui/: ok.
- GOOS=linux go vet -tags nogui and GOOS=windows go vet ./internal/sessions/: ok; gofmt -l clean.
- Windows box (win-run): -run 'TestZCode|TestSessionTitles' ./internal/sessions/: ok.
Broken by hand: with origin/main's sessions.go, TestZCodeForkTitlesByRequestID
fails: fork by request id: "", want "Fork of The parent session's title".
Not tried: a real ZCode database here (none on this machine); the
reporter ran the patch against theirs on Windows and got the fork's own
title and the parent's.
#5365, Flandern1211 (report, patch, test).
Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>
226fc8ea3 lists ZCode's sessions for Titles from their rows alone, with
size 0 and the row's time_updated as the file's stamp. Two things followed
from that stamp:
- ZCode writes a message without touching its session's row, so a session
still under its default title, first read before its prompt was in, was
never named by that prompt while only the Routing page polled.
- The cache kept size 0 and the row's time, where the Sessions page's
listing (zcodeFiles) keeps the message count and the last message's
time, so each read the session whole again after the other.
zcodeTitleStamps gives the sessions a poll asks for (their key wanted,
subagents under it too) the same count and last activity, from a
COUNT/MAX over each one's own messages by session_id, not the join over
every session's. A session whose messages can't be read keeps its row's
stamp, as before.
Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>
Run (mote, via mote-run):
- go test ./internal/sessions -run TestZCode -count=1 at 226fc8ea3 alone:
TestZCodeTitlesSeeNewMessages red (after the prompt: "") and
TestZCodeTitlesKeepTheListingsStamp red (kept size 0 mod
1790496000000000000, listing has size 3 mod 1790496030000000000). With
this change both green. On origin/main 1b0340fdb both pass (the poll
read the join), while 226fc8ea3's TestZCodeSubagentTitlesByRequestID and
TestZCodeTitlesWithoutMessageTable are red there.
- go test -timeout 45m ./internal/sessions ./internal/gui -count=1: sessions
ok; gui ok but TestMainWindowCorners/macOS_26_SDK, #3949 (mote is
macOS 27), untouched here.
- GOOS=linux and GOOS=windows go vet ./internal/sessions: ok. gofmt clean.
Not tried: a real ZCode database (none on this Mac or the Windows box);
the per-session COUNT/MAX is not timed against the reporter's 1 GB one.
It filters message by session_id, as parseOpenCode's own reads do.
Titles listed every agent's files, and zcodeFiles joins the message table to give each session its size and last activity. On a ZCode database of 1,022 sessions and about 1 GB of messages that join took ~20 s, while the Routing page asks again every 15 s: its cards showed the folder for a while, and a poll that came back empty dropped a name it had.
Titles now lists ZCode's sessions from their own rows (zcodeTitleFiles: id, parent, time_updated) and names them through the same assembleListed/parseOpenCode path as before. A ZCode subagent, which ocRoots files under its parent's key, is named from its own file's cached row when the key asked for matches no group.
Run:
- go test ./internal/sessions -run 'TestZCodeTitlesByRequestID|TestZCodeSubagentTitlesByRequestID|TestZCodeTitlesWithoutMessageTable|TestZCodeDefaultTitleFallsBackToFirstPrompt|TestSessionTitles|TestZCodeCalls' -count=1: ok.
- go test ./internal/gui -run TestSessionTitlesNameOtherAgents -count=1: ok.
- Broken by hand: with zcodeFiles (the message join) in place, TestZCodeTitlesWithoutMessageTable fails with an empty title; with the subagent fallback removed, TestZCodeSubagentTitlesByRequestID fails; with the sess_ alias removed, TestZCodeTitlesByRequestID fails.
- Real ZCode database on Windows: Titles for three live sessions went from 20.4 s to 780 ms cold and 74 ms warm; a ZCode and dsh poll took 80-160 ms.
- go build ./...: ok. The full sessions package has the same three Windows-only failures as before this change (TestAgySessions, TestAgyRowOnly, TestCCListingKeepsItsNames).
ZCode sends its session id to the gateway without the sess_ prefix stored
in its database. Routing asks Titles with that bare id, gets no title, and
falls back to the folder name even though the Sessions page can show the
real title.
Titles treats zcode:<id> as an alias for zcode:sess_<id> when it reads
local session files, and returns the title under the key Routing asked
for (the sess_ key too, which callers ignore). A regression test uses the
database id shape ZCode writes and the bare request id it sends.
Ported from Flandern's b1a952b73 (fix/zcode-routing-session-titles on
flandern12111/magpie), code and test unchanged, reviewed line by line;
the body is rewritten (the original had literal \n's), and
gateway-sessions.md says it.
Run on mote via mote-run, at origin/main c7bbd3faf plus the change before
this one: go test ./internal/sessions -run
'TestZCodeTitlesByRequestID|TestSessionTitles|TestTitles|TestZCode'
-count=1: ok. Again at this commit on origin/main 14f6d10de: go test
./internal/sessions -count=1 ok.
Pushed on c4245c4c2, which changes only internal/gateway's
object_root and its doc after 14f6d10de; not run again on it.
Broken by hand: the alias lookup removed, TestZCodeTitlesByRequestID red
("zcode:578bd3d1-…: title \"\", want \"A ZCode session's title\"").
Not tried: a real ZCode session through a running gateway.
Co-authored-by: Flandern <3180066912wzw@gmail.com>