sessions: an Antigravity app conversation shows what was said, not only its title

@yansheng1003 on X: the Sessions page showed an Antigravity 2.0
conversation's title and preview only. HasTranscript left "antigravity"
out, since conversations/<id>.db's step text is encrypted at rest, so
the row had no Show conversation and /api/sessions/transcript said
"this agent's conversations can't be shown".

The app also writes every step in plain text beside the database:
brain/<id>/.system_generated/logs/transcript_full.jsonl in the same
store, in agy CLI's format (user input, planner responses with their
tool_calls, tool results). Antigravity 2.30's language server writes it
in the stable store and in Insiders' (both checked: run in a sandbox
HOME on Windows against a fake model that called read_file).

- transcript.go: antigravity has a transcript; readTranscriptOf reads
  it through agyTranscript (antigravityTranscriptOf), so the viewer,
  TranscriptAt, search, the said index and the Markdown export all get
  it. A conversation with no transcript file is ErrNoTranscript, as
  before.
- antigravity_app.go: antigravityTranscript derives the path from the
  database's (stable, Insiders, a WSL distro's); its size and time are
  folded into the session file's with the -wal's, so a step it adds
  reads the session and the said index again.
- search.go: linesFile is false for antigravity, so the encrypted .db is
  never pre-scanned for the words.
- testdata/antigravity-2.30-tools: that real conversation (db with the
  WAL checkpointed, summary row, brain/ logs).

Tests: TestAntigravityAppTranscript (stable, Insiders, WSL: parts, search
hit and miss, Markdown), TestAntigravityAppNoTranscript,
internal/gui TestSessionAntigravityConversation (/api/sessions marks it,
/api/sessions/transcript gives the five parts).

Run: on mica (mica-run) at base de5fc6700:
- gofmt -l internal/sessions internal/gui: clean.
- go vet ./internal/sessions ./internal/gui, GOOS=linux go vet -tags
  nogui and GOOS=windows go vet on the same, go build .: ok.
- go test -count=1 -timeout 45m ./internal/sessions: ok but for
  TestWSLAgentsGoneListingDrops (load ~48; fixed at its cause in the
  commit before this one); go test ./internal/gui: ok (299s).
- After that fix: go test -run 'WSL|Antigravity|Agy|Gone'
  ./internal/sessions ok; GUI files sessions-talk, -talk-sheet,
  -talk-model, -export, -said, -subagents, -reads, -search, -convert:
  168 of 168 in Chromium and WebKit.
- Old code (de5fc6700 with only the new tests and testdata):
  TestAntigravityAppTranscript red in stable, insiders and wsl ("the
  session isn't marked readable"), TestSessionAntigravityConversation
  red ("listed with no conversation to show ... Transcript:false").
- Windows (win-run on xiaomi-gpu): TestAntigravityAppTranscript (3
  subtests) and TestAntigravityAppNoTranscript pass.
  TestAntigravityAppFolder is red there at the base as well (#5957).
Rebased onto bfddc9cfb, on mote (mote-run) at this tree: gofmt clean,
the three vets and go build ok, go test -count=1 ./internal/sessions
./internal/gui ok (56s, 157s).
Not tried: the real GUI window opening this conversation; the API and
page are covered by the tests above.
This commit is contained in:
yetone
2026-11-18 18:55:46 +08:00
parent 65c9a2e411
commit d2fa7d8d79
12 changed files with 256 additions and 8 deletions
+13 -1
View File
@@ -1019,10 +1019,22 @@ including response folding and gateway matching. Insiders session ids
have an `insiders-` prefix in magpie, leaving stable ids unchanged and
keeping equal UUIDs in the two stores from sharing a session or call id.
The files themselves are not renamed. Sessions stay read-only with no
terminal resume command; encrypted conversation text is not read.
terminal resume command. The database's step text is encrypted and not
read; what was said is read from the plain-text transcript the app writes
beside it, `brain/<id>/.system_generated/logs/transcript_full.jsonl` in the
same store (`antigravityTranscript`), in agy's format and through agy's
reader (`agyTranscript`): the user's turns, the replies, each tool call and
its result, on the session viewer, search and the Markdown export
(@yansheng1003 on X: only the title and preview showed). Its size and time
are counted into the session file's with the `-wal`'s, so a step it adds
reads the session again. A conversation with no transcript is
`ErrNoTranscript`, as before.
Verification: `TestAntigravityInsidersSessions` covers Insiders alone,
both stores with the same UUID, per-model tokens, call ids, summary refresh
and turning the existing reading choice off, using #2190's real step bytes.
`TestAntigravityAppTranscript` reads a conversation the app's 2.30 language
server had with a read_file call (testdata/antigravity-2.30-tools) from
stable, Insiders and a WSL distro's store; `TestAntigravityAppNoTranscript`.
A read of every call decodes each file's cached shard, and over a long
history that is tens of thousands of files (#2278: 68k shards, 415 MB).
+82
View File
@@ -0,0 +1,82 @@
package gui
import (
"encoding/json"
"net/http"
"net/http/httptest"
"path/filepath"
"strings"
"testing"
"github.com/yetone/magpie/internal/sessions"
"github.com/yetone/magpie/internal/settings"
)
// @yansheng1003 on X: an Antigravity 2.0 conversation showed only its
// title and preview. The Sessions list marks it as one whose conversation
// can be shown, and /api/sessions/transcript, which Show conversation
// asks, gives what was said: the user's turn, the replies, the tool call
// and its result, read from the transcript the app's 2.30 language server
// wrote (sessions' testdata/antigravity-2.30-tools).
func TestSessionAntigravityConversation(t *testing.T) {
h := sandboxHome(t)
copyTree(t, "../sessions/testdata/antigravity-2.30-tools", filepath.Join(h, ".gemini", "antigravity"))
if err := settings.SetSessionReads(func(*settings.SessionReads) *settings.SessionReads {
return &settings.SessionReads{Asked: true, All: true}
}); err != nil {
t.Fatal(err)
}
sessions.Reset()
t.Cleanup(sessions.Reset)
const id = "a9b3e500-3594-49ed-b821-3418225e1990"
mux := http.NewServeMux()
sessionRoutes(mux, folderOnly{})
get := func(path string) []byte {
t.Helper()
w := httptest.NewRecorder()
mux.ServeHTTP(w, httptest.NewRequest("GET", path, nil))
if w.Code != 200 {
t.Fatalf("%s: %d %s", path, w.Code, w.Body)
}
return w.Body.Bytes()
}
var list struct {
Sessions []struct {
Agent, ID string
Transcript bool
}
}
if err := json.Unmarshal(get("/api/sessions"), &list); err != nil {
t.Fatal(err)
}
listed := false
for _, s := range list.Sessions {
if s.Agent == "antigravity" && s.ID == id {
listed = true
if !s.Transcript {
t.Fatalf("listed with no conversation to show: %+v", s)
}
}
}
if !listed {
t.Fatalf("not listed: %+v", list.Sessions)
}
var tr sessions.Transcript
if err := json.Unmarshal(get("/api/sessions/transcript?agent=antigravity&id="+id), &tr); err != nil {
t.Fatal(err)
}
var said []string
for _, p := range tr.Parts {
said = append(said, p.Role+"/"+p.Kind+"/"+p.Name+": "+p.Text)
}
want := []string{
"user/text/: read a.txt",
"assistant/text/: Let me read it.",
`assistant/tool_use/read_file: {"Path":"C:\\Users\\yeton\\agyss\\e2e4\\home\\proj\\a.txt"}`,
"tool/tool_result/: Showing lines 1-1 of 1\n1: hi",
"assistant/text/: a.txt says hi.",
}
if strings.Join(said, "\n|") != strings.Join(want, "\n|") {
t.Fatalf("transcript\n%s\nwant\n%s", strings.Join(said, "\n|"), strings.Join(want, "\n|"))
}
}
+31 -5
View File
@@ -23,7 +23,11 @@ import (
// ~/.gemini/antigravity/conversations/<conversation id>.db (Insiders uses
// ~/.gemini/antigravity-insiders/conversations), written in WAL
// mode while it runs. Its messages are encrypted at rest; the figures read
// here are not. As Antigravity 2.23.0 on macOS writes them (yygutn's real
// here are not. What was said is also written in plain text beside it,
// brain/<conversation id>/.system_generated/logs/transcript_full.jsonl
// (antigravityTranscript): the steps as agy CLI writes them, user turns,
// replies, tool calls and their results, which the session viewer reads
// (@yansheng1003 on X: it showed only the title and preview). As Antigravity 2.23.0 on macOS writes them (yygutn's real
// rows on #2190; the app isn't installed on any machine magpie is tried on):
//
// steps idx, metadata BLOB, …: one row a step
@@ -130,10 +134,12 @@ func antigravityFilesIn(dir, goos string) []file {
if !stat(&f) {
continue
}
if fi, err := os.Stat(f.path + "-wal"); err == nil {
f.size += fi.Size()
if fi.ModTime().After(f.mod.Time()) {
f.mod = modOf(fi.ModTime())
for _, p := range []string{f.path + "-wal", antigravityTranscript(f.path)} {
if fi, err := os.Stat(p); err == nil {
f.size += fi.Size()
if fi.ModTime().After(f.mod.Time()) {
f.mod = modOf(fi.ModTime())
}
}
}
if r, ok := rows[id]; ok {
@@ -145,6 +151,26 @@ func antigravityFilesIn(dir, goos string) []file {
return out
}
// antigravityTranscript is the plain-text transcript of the conversation
// whose database is db: brain/<id>/.system_generated/logs/transcript_full.jsonl
// in the same data folder (stable's, Insiders' or a WSL distro's), as
// Antigravity 2.30 writes it. Its size and time are the session file's
// too (antigravityFilesIn), so a step it adds reads the session again.
func antigravityTranscript(db string) string {
id := strings.TrimSuffix(filepath.Base(db), ".db")
return filepath.Join(filepath.Dir(filepath.Dir(db)), "brain", id, ".system_generated", "logs", "transcript_full.jsonl")
}
// antigravityTranscriptOf reads the conversation whose database is db from
// its transcript, as agy's; ErrNoTranscript when the app wrote none.
func antigravityTranscriptOf(db string, keep func([]byte) bool, add func(bool, Part) bool) error {
p := antigravityTranscript(db)
if _, err := os.Stat(p); errors.Is(err, os.ErrNotExist) {
return ErrNoTranscript
}
return agyTranscript(p, keep, add)
}
// antigravityCallFiles are the same databases as call sources.
func antigravityCallFiles() []file { return antigravityFiles() }
@@ -0,0 +1,108 @@
package sessions
import (
"context"
"errors"
"path/filepath"
"strings"
"testing"
)
// testdata/antigravity-2.30-tools is the Antigravity app's data folder
// after one conversation its 2.30 language server had in a sandbox HOME on
// Windows, against a fake model that called read_file once: the
// conversation's database (its steps' text encrypted), its summary row, and
// brain/<id>/.system_generated/logs/transcript_full.jsonl, the steps in
// plain text.
const agAppTools = "a9b3e500-3594-49ed-b821-3418225e1990"
// agAppToolsParts are what that conversation said.
var agAppToolsParts = []Part{
{Role: "user", Kind: "text", Text: "read a.txt"},
{Role: "assistant", Kind: "text", Text: "Let me read it."},
{Role: "assistant", Kind: "tool_use", Name: "read_file", Text: `{"Path":"C:\\Users\\yeton\\agyss\\e2e4\\home\\proj\\a.txt"}`},
{Role: "tool", Kind: "tool_result", Text: "Showing lines 1-1 of 1\n1: hi"},
{Role: "assistant", Kind: "text", Text: "a.txt says hi."},
}
func wantAgAppTools(t *testing.T, s Session) {
t.Helper()
if !s.Transcript {
t.Fatalf("the session isn't marked readable: %+v", s)
}
tr, err := TranscriptOf(s)
if err != nil {
t.Fatal(err)
}
if len(tr.Parts) != len(agAppToolsParts) {
t.Fatalf("parts %+v", tr.Parts)
}
for i, p := range agAppToolsParts {
if tr.Parts[i] != p {
t.Errorf("part %d %+v, want %+v", i, tr.Parts[i], p)
}
}
}
// @yansheng1003 on X: an Antigravity 2.0 conversation showed only its
// title and preview on the Sessions page, not what was said. The app's
// transcript beside the database is read as agy's is: the user's turn,
// the replies, the tool call and its result; found by search, and in the
// Markdown export. Stable's, Insiders' and a WSL distro's.
func TestAntigravityAppTranscript(t *testing.T) {
t.Run("stable", func(t *testing.T) {
claude, _ := setup(t)
home := filepath.Join(filepath.Dir(claude), "home")
copyTree(t, "testdata/antigravity-2.30-tools", filepath.Join(home, ".gemini", "antigravity"))
Reset()
s := find(t, List(0), "antigravity", agAppTools)
if s.Title != "a.txt says hi." {
t.Errorf("title %q", s.Title)
}
wantAgAppTools(t, s)
if _, found, err := SearchSession(context.Background(), s, NeedleOf("says hi")); err != nil || !found {
t.Errorf("search: found %v, %v", found, err)
}
if _, found, _ := SearchSession(context.Background(), s, NeedleOf("never said")); found {
t.Error("search found words never said")
}
var b strings.Builder
if err := WriteMarkdown(&b, s, "Antigravity"); err != nil {
t.Fatal(err)
}
for _, w := range []string{"read a.txt", "read_file", "a.txt says hi."} {
if !strings.Contains(b.String(), w) {
t.Errorf("markdown has no %q:\n%s", w, b.String())
}
}
})
t.Run("insiders", func(t *testing.T) {
claude, _ := setup(t)
home := filepath.Join(filepath.Dir(claude), "home")
copyTree(t, "testdata/antigravity-2.30-tools", filepath.Join(home, ".gemini", "antigravity-insiders"))
Reset()
wantAgAppTools(t, find(t, List(0), "antigravity", "insiders-"+agAppTools))
})
t.Run("wsl", func(t *testing.T) {
home, _ := wslDistro(t)
copyTree(t, "testdata/antigravity-2.30-tools", filepath.Join(home, ".gemini", "antigravity"))
s := find(t, List(0), "antigravity", agAppTools)
if s.WSL == "" {
t.Fatalf("not the distro's: %+v", s)
}
wantAgAppTools(t, s)
})
}
// A conversation the app wrote no transcript for (antigravityFixture's,
// from #2190's rows) can't be shown, as before.
func TestAntigravityAppNoTranscript(t *testing.T) {
claude, _ := setup(t)
home := filepath.Join(filepath.Dir(claude), "home")
const id = "37c3c786-9a11-44be-97df-b8fc1ccebc78"
antigravityFixture(t, home, id)
Reset()
if _, err := TranscriptOf(find(t, List(0), "antigravity", id)); !errors.Is(err, ErrNoTranscript) {
t.Fatalf("err %v, want ErrNoTranscript", err)
}
}
+3 -1
View File
@@ -264,9 +264,11 @@ func SearchSession(ctx context.Context, s Session, needle string) (Hit, bool, er
// so that one without the needle's bytes can be passed over unread. An
// OpenCode session's is its info (the messages are elsewhere) or a database,
// and a Cursor chat's a database too, whose newest pages are in its -wal.
// An Antigravity app conversation's is its database, the transcript beside
// it.
func linesFile(s Session) bool {
switch s.Agent {
case "opencode":
case "opencode", "antigravity":
return false
case "cursor":
return strings.HasSuffix(s.Path, ".jsonl")
@@ -0,0 +1,4 @@
{"step_index":0,"source":"USER_EXPLICIT","type":"USER_INPUT","status":"DONE","created_at":"2026-11-18T08:25:49Z","content":"<USER_REQUEST>\nread a.txt\n</USER_REQUEST>\n<ADDITIONAL_METADATA>\nThe current local time is: 2026-11-18T16:25:49+08:00.\n</ADDITIONAL_METADATA>\n<USER_SETTINGS_CHANGE>\nThe user changed setting `Model Selection` from None to g3. No need to comment on this change if the user doesn't ask about it. If reporting what model you are, please use a human readable name instead of the exact string.\n</USER_SETTINGS_CHANGE>"}
{"step_index":1,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-18T08:25:50Z","input_tokens":1000,"cache_read_tokens":200,"output_tokens":7,"content":"Let me read it.","tool_calls":[{"name":"read_file","args":{"Path":"\"C:\\\\Users\\\\yeton\\\\agyss\\\\e2e4\\\\home\\\\proj\\\\a.txt\""}}]}
{"step_index":2,"source":"MODEL","type":"GENERIC","status":"DONE","created_at":"2026-11-18T08:25:50Z","content":"Created At: 2026-11-18T16:25:50+08:00\nCompleted At: 2026-11-18T16:25:50+08:00\nShowing lines 1-1 of 1\n1: hi\r"}
{"step_index":3,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-18T08:25:50Z","input_tokens":1000,"cache_read_tokens":200,"output_tokens":7,"content":"a.txt says hi."}
@@ -0,0 +1,4 @@
{"step_index":0,"source":"USER_EXPLICIT","type":"USER_INPUT","status":"DONE","created_at":"2026-11-18T08:25:49Z","content":"<USER_REQUEST>\nread a.txt\n</USER_REQUEST>\n<ADDITIONAL_METADATA>\nThe current local time is: 2026-11-18T16:25:49+08:00.\n</ADDITIONAL_METADATA>\n<USER_SETTINGS_CHANGE>\nThe user changed setting `Model Selection` from None to g3. No need to comment on this change if the user doesn't ask about it. If reporting what model you are, please use a human readable name instead of the exact string.\n</USER_SETTINGS_CHANGE>"}
{"step_index":1,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-18T08:25:50Z","input_tokens":1000,"cache_read_tokens":200,"output_tokens":7,"content":"Let me read it.","tool_calls":[{"name":"read_file","args":{"Path":"C:\\Users\\yeton\\agyss\\e2e4\\home\\proj\\a.txt"}}]}
{"step_index":2,"source":"MODEL","type":"GENERIC","status":"DONE","created_at":"2026-11-18T08:25:50Z","content":"Created At: 2026-11-18T16:25:50+08:00\nCompleted At: 2026-11-18T16:25:50+08:00\nShowing lines 1-1 of 1\n1: hi\r"}
{"step_index":3,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-18T08:25:50Z","input_tokens":1000,"cache_read_tokens":200,"output_tokens":7,"content":"a.txt says hi."}
@@ -0,0 +1,4 @@
{"step_index":0,"source":"USER_EXPLICIT","type":"USER_INPUT","status":"DONE","created_at":"2026-11-18T08:25:49Z","content":"<USER_REQUEST>\nread a.txt\n</USER_REQUEST>\n<ADDITIONAL_METADATA>\nThe current local time is: 2026-11-18T16:25:49+08:00.\n</ADDITIONAL_METADATA>\n<USER_SETTINGS_CHANGE>\nThe user changed setting `Model Selection` from None to g3. No need to comment on this change if the user doesn't ask about it. If reporting what model you are, please use a human readable name instead of the exact string.\n</USER_SETTINGS_CHANGE>"}
{"step_index":1,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-18T08:25:50Z","input_tokens":1000,"cache_read_tokens":200,"output_tokens":7,"content":"Let me read it.","tool_calls":[{"name":"read_file","args":{"Path":"\"C:\\\\Users\\\\yeton\\\\agyss\\\\e2e4\\\\home\\\\proj\\\\a.txt\""}}]}
{"step_index":2,"source":"MODEL","type":"GENERIC","status":"DONE","created_at":"2026-11-18T08:25:50Z","content":"Created At: 2026-11-18T16:25:50+08:00\nCompleted At: 2026-11-18T16:25:50+08:00\nShowing lines 1-1 of 1\n1: hi\r"}
{"step_index":3,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-18T08:25:50Z","input_tokens":1000,"cache_read_tokens":200,"output_tokens":7,"content":"a.txt says hi."}
@@ -0,0 +1,4 @@
{"step_index":0,"source":"USER_EXPLICIT","type":"USER_INPUT","status":"DONE","created_at":"2026-11-18T08:25:49Z","content":"<USER_REQUEST>\nread a.txt\n</USER_REQUEST>\n<ADDITIONAL_METADATA>\nThe current local time is: 2026-11-18T16:25:49+08:00.\n</ADDITIONAL_METADATA>\n<USER_SETTINGS_CHANGE>\nThe user changed setting `Model Selection` from None to g3. No need to comment on this change if the user doesn't ask about it. If reporting what model you are, please use a human readable name instead of the exact string.\n</USER_SETTINGS_CHANGE>"}
{"step_index":1,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-18T08:25:50Z","input_tokens":1000,"cache_read_tokens":200,"output_tokens":7,"content":"Let me read it.","tool_calls":[{"name":"read_file","args":{"Path":"C:\\Users\\yeton\\agyss\\e2e4\\home\\proj\\a.txt"}}]}
{"step_index":2,"source":"MODEL","type":"GENERIC","status":"DONE","created_at":"2026-11-18T08:25:50Z","content":"Created At: 2026-11-18T16:25:50+08:00\nCompleted At: 2026-11-18T16:25:50+08:00\nShowing lines 1-1 of 1\n1: hi\r"}
{"step_index":3,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-18T08:25:50Z","input_tokens":1000,"cache_read_tokens":200,"output_tokens":7,"content":"a.txt says hi."}
+3 -1
View File
@@ -35,7 +35,7 @@ var ErrNoTranscript = errors.New("this agent's conversations can't be shown")
// transcript.
func HasTranscript(agent string) bool {
switch agent {
case "claude", "qoder", "qoder-cn", "codex", "pi", "raft", "cindy", "omp", "cursor", "opencode", "kimi", "agy", "openmausbot", "liveagent":
case "claude", "qoder", "qoder-cn", "codex", "pi", "raft", "cindy", "omp", "cursor", "opencode", "kimi", "agy", "antigravity", "openmausbot", "liveagent":
return true
}
return false
@@ -162,6 +162,8 @@ func readTranscriptOf(s Session, keep func([]byte) bool, add func(bool, Part) bo
return kimiTranscript(s.Path, keep, add)
case "agy":
return agyTranscript(s.Path, keep, add)
case "antigravity":
return antigravityTranscriptOf(s.Path, keep, add)
case "openmausbot":
return ombTranscript(s, add)
case "liveagent":