Files
magpie/internal/sessions/cindy.go
T
yetone 7da5b34aa4 sessions: Cindy's Pi sessions are read from its pi-agent-home (ldl123292 on X)
Cindy starts Pi with --session-dir <userData>/pi-agent-home/sessions
(resolvePiAgentHome in Cindy's app.asar), so its Pi sessions never
reached ~/.pi/agent and magpie showed none of them. They are read now from
the Cindy and CindyGlobal builds' folders and listed as Cindy's: list,
transcript, calls on Usage, Dirs, delete, and the gateway's own record of
a Cindy session merged with the file's.

Run (mote): go test ./internal/sessions ./internal/agent ./internal/usage
ok. go test ./internal/gui: two reds, both the same on origin/main
699ddf152: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners (#3949). Linux (wsl-run): go test -run
'Cindy|Raft|TestPi' ./internal/sessions ok. gofmt clean.
Broken by hand: without cindyFiles() in the sessions list both Cindy tests
fail (0 Cindy sessions, want 4).
Not tried: a real Pi session run in Cindy (none on this Mac; the fixtures
are Pi 1.1.0's own files put where Cindy's Pi writes them), Windows, the
full suite. Cindy's Codex in <userData>/codex-home is not read yet: #4651.
2026-11-01 09:12:11 +08:00

51 lines
1.5 KiB
Go

package sessions
import (
"os"
"path/filepath"
)
// Cindy (a desktop app that runs Claude Code, Codex and Pi) starts Pi with
// --session-dir <its data>/pi-agent-home/sessions: Pi's SDK files,
// <time>_<session id>.jsonl, all in one folder (Cindy 0.x's
// resolvePiAgentHome, the userData folder Electron gives it). They are read
// as Pi's, as agent "cindy", which is what the gateway counts their
// requests as (Cindy's key). Before, Pi's own folder was read and Cindy's
// never, so a user running Pi in Cindy saw no session of it at all
// (ldl123292 on X). Cindy's Claude Code writes to ~/.claude, read as
// Claude Code's already.
// CindyDirs are Cindy's data folders, Cindy and CindyGlobal (its global
// build), under the user's config folder (~/Library/Application Support,
// %APPDATA%, $XDG_CONFIG_HOME or ~/.config).
func CindyDirs() []string {
d, err := os.UserConfigDir()
if err != nil {
return nil
}
return []string{filepath.Join(d, "Cindy"), filepath.Join(d, "CindyGlobal")}
}
func cindySessionDirs() []string {
var out []string
for _, d := range CindyDirs() {
out = append(out, filepath.Join(d, "pi-agent-home", "sessions"))
}
return out
}
func cindyFiles() []file { return cindyFilesIn(cindySessionDirs()) }
// cindyFilesIn are the Pi sessions in Cindy's session folders.
func cindyFilesIn(dirs []string) []file {
if !Reads("cindy") {
return nil
}
var paths []string
for _, d := range dirs {
more, _ := filepath.Glob(filepath.Join(d, "*.jsonl"))
paths = append(paths, more...)
}
return piNamed("cindy", paths)
}