Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

sessions: Raft's Pi agents' sessions are listed as Raft's, with their prompts, calls and delete

yetone9474eaf9cbbd
diff --git a/docs/subsystems/gateway-sessions.md b/docs/subsystems/gateway-sessions.md
index 56f330133..9603e53d8 100644
--- a/docs/subsystems/gateway-sessions.md
+++ b/docs/subsystems/gateway-sessions.md
@@ -43,7 +43,20 @@ user's own llm-deepseek row pointed at magpie relies on (#3298,
`TestDshMarksOnEveryRoute`).
When the same identity is present in a native session, the native session wins
-and the gateway projection is omitted. On `/api/sessions/manage`, in its
+and the gateway projection is omitted. A native session can stand for more
+than its own key (`sessions.GatewayKeys`): Raft's (slock's raft-computer)
+agents run Pi in their folders under `$SLOCK_HOME` (else `~/.slock`,
+`%USERPROFILE%\.slock` on Windows), `agents/<id>/.pi-sessions/` and
+`.builtin-sessions/`, Pi's SDK files read as agent `raft`
+([`raft.go`](../../internal/sessions/raft.go)). Raft's Pi reads the user's
+own Pi folder, so through magpie it says it is Pi, and a Raft session is
+the gateway's `pi|<id>` too: in `MergeExternal`, the stats' native keys,
+the GUI's list and Via, and `NativeIDs` for `pi`. Raft's sessions are
+listed, read and deleted as Pi's (one file to the trash, nothing beside
+it; Raft starts afresh without it), with no resume command, no carry and
+no trace export (the gateway's Pi identity has those calls). Verification:
+`TestRaftSessions`, `TestRaftIsPiToTheGateway`, `TestRaftDeleteRestore`,
+`TestRaftSlockHome`. On `/api/sessions/manage`, in its
counts as in its list, and on `/api/sessions/delete`, a native session is any
session file the agent keeps, one nothing was said in too, with no limit
(`sessions.NativeIDs`); one pass over the agents' files (`sessions.Manage`)
@@ -436,8 +449,8 @@ Code's (#1779; its sessions are on the Sessions page too, from the same
`projects/<cwd>/<id>.jsonl` files read as WorkBuddy's, resumed with
`codebuddy --resume <id>` and deletable, #2657: `TestCodeBuddy`,
`TestCodeBuddySessionsListedUnderTheirName`), MiniMax Code's (#1605), Kimi Code's (#1607,
-[`calls_kimi.go`](../../internal/sessions/calls_kimi.go)) and Pi's and
-omp's, here and in WSL (#1951,
+[`calls_kimi.go`](../../internal/sessions/calls_kimi.go)) and Pi's,
+Raft's Pi agents' and omp's, here and in WSL (#1951,
[`calls_pi.go`](../../internal/sessions/calls_pi.go)). Each skips the
calls the agent made through magpie's own entry, which the gateway logged
with the account that answered: Kimi Code's are the ones whose
diff --git a/internal/agent/agents.go b/internal/agent/agents.go
index 7be56d7dc..1967e0e5b 100644
--- a/internal/agent/agents.go
+++ b/internal/agent/agents.go
@@ -105,6 +105,10 @@ var others = []*Agent{
// ("pi-desktop/0.1.0"), it is told apart from Pi by that name, which
// Pi's "pi-" would take otherwise (#1966, dgmico)
{ID: "pi-desktop", Name: "PI-Desktop", Icon: "pi", UA: []string{"pi-desktop"}},
+ // Raft (slock's raft-computer) runs Pi in each of its agents' folders;
+ // Sessions lists those as Raft's (internal/sessions/raft.go), while
+ // their requests say "pi (…)" and are Pi's
+ {ID: "raft", Name: "Raft", Icon: "generic"},
}
// Clients is everyone whose requests the gateway knows by name: every
diff --git a/internal/agentenv/agentenv.go b/internal/agentenv/agentenv.go
index 05d59da96..5cfcd8bb8 100644
--- a/internal/agentenv/agentenv.go
+++ b/internal/agentenv/agentenv.go
@@ -43,6 +43,8 @@ var Vars = []string{
// Pi and its forks (OmO, Senpi), whose profile and config are apart
"PI_CODING_AGENT_DIR", "PI_CODING_AGENT_SESSION_DIR", "PI_CONFIG_DIR", "PI_PROFILE",
"OMO_CODING_AGENT_DIR", "SENPI_CODING_AGENT_DIR",
+ // Raft (slock), whose agents keep their Pi sessions in its folder
+ "SLOCK_HOME",
"PRIME_AGENT_CODING_AGENT_DIR",
// StepCode: config root resolution and folder overrides
"STEP_CODING_AGENT_DIR", "STEPCODE_CONFIG_DIR",
diff --git a/internal/gui/sessions.go b/internal/gui/sessions.go
index 49325af6a..0d4476462 100644
--- a/internal/gui/sessions.go
+++ b/internal/gui/sessions.go
@@ -106,7 +106,9 @@ func sessionRoutes(mux *http.ServeMux, w Windows) {
list := sessions.List(sessions.All)
nativeKeys := map[string]bool{}
for _, s := range list {
- nativeKeys[s.Agent+"|"+s.ID] = true
+ for _, k := range sessions.GatewayKeys(s) {
+ nativeKeys[k] = true
+ }
// a copy of its conversation is the agent's own too
for _, id := range s.Copies {
nativeKeys[s.Agent+"|"+id] = true
@@ -139,7 +141,7 @@ func sessionRoutes(mux *http.ServeMux, w Windows) {
}
vias := usage.Vias(since.Add(-time.Minute))
for _, s := range list {
- j := sessionJSON{Session: s, Name: s.Agent, Icon: "generic", Via: vias.Of(s.Agent + "|" + s.ID)}
+ j := sessionJSON{Session: s, Name: s.Agent, Icon: "generic", Via: viaOf(vias, s)}
if a := agents[s.Agent]; a != nil {
j.Name, j.Icon = a.SharedName(), a.Icon
}
@@ -250,7 +252,7 @@ func sessionRoutes(mux *http.ServeMux, w Windows) {
if since.IsZero() {
since = s.Last
}
- j.Via = usage.Vias(since.Add(-time.Minute)).Of(s.Agent + "|" + s.ID)
+ j.Via = viaOf(usage.Vias(since.Add(-time.Minute)), s)
j.Path = tilde(j.Path)
writeJSON(rw, j)
})
@@ -744,3 +746,14 @@ func openTerminal(command, choice string) error {
time.AfterFunc(time.Minute, func() { os.Remove(f.Name()) })
return nil
}
+
+// viaOf is what the gateway sent a session's calls to, under any key its
+// gateway record can carry (sessions.GatewayKeys: Raft's Pi says it is Pi).
+func viaOf(x usage.ViaIndex, s sessions.Session) []usage.Via {
+ for _, k := range sessions.GatewayKeys(s) {
+ if v := x.Of(k); v != nil {
+ return v
+ }
+ }
+ return nil
+}
diff --git a/internal/gui/sessions_manage.go b/internal/gui/sessions_manage.go
index 27de91d92..a27bd9ae6 100644
--- a/internal/gui/sessions_manage.go
+++ b/internal/gui/sessions_manage.go
@@ -215,7 +215,7 @@ func sessionManageRoutes(mux *http.ServeMux, w Windows) {
vias := usage.Vias(since.Add(-time.Minute))
for _, s := range list {
s.Path = tilde(s.Path)
- out.Sessions = append(out.Sessions, managedJSON{Managed: s, Via: vias.Of(s.Agent + "|" + s.ID)})
+ out.Sessions = append(out.Sessions, managedJSON{Managed: s, Via: viaOf(vias, s.Session)})
}
sizes := sessions.GatewaySizes()
for _, g := range gateway {
diff --git a/internal/sessions/call_cache.go b/internal/sessions/call_cache.go
index 6479ab004..11d52f5e2 100644
--- a/internal/sessions/call_cache.go
+++ b/internal/sessions/call_cache.go
@@ -247,6 +247,7 @@ type lineCallReader struct {
var lineCallReaders = map[string]lineCallReader{
"kimi": {kimiCallsBegin, kimiCallLine, nil}, // #1607
"pi": {piCallsBegin, readPiCallLine, piCallsKept}, // #1951
+ "raft": {piCallsBegin, readPiCallLine, piCallsKept},
"omp": {piCallsBegin, readPiCallLine, piCallsKept},
}
diff --git a/internal/sessions/calls_pi.go b/internal/sessions/calls_pi.go
index a9e161f90..c1f38ad55 100644
--- a/internal/sessions/calls_pi.go
+++ b/internal/sessions/calls_pi.go
@@ -41,8 +41,9 @@ import (
// piCallFiles are Pi's and omp's session files, here and in WSL.
func piCallFiles() []file {
- out := append(piFiles(), ompFiles()...)
- return append(out, wslFiles("pi", "omp")...)
+ out := append(piFiles(), raftFiles()...)
+ out = append(out, ompFiles()...)
+ return append(out, wslFiles("pi", "raft", "omp")...)
}
// piGateway is whether a provider is magpie's own entry.
diff --git a/internal/sessions/external.go b/internal/sessions/external.go
index f632f516b..f5d0ad7ac 100644
--- a/internal/sessions/external.go
+++ b/internal/sessions/external.go
@@ -36,7 +36,9 @@ func MergeExternal(native []Session, external []ExternalSession) []Session {
names := desktopExternalTitles(external)
seen := map[string]bool{}
for _, s := range native {
- seen[s.Agent+"|"+s.ID] = true
+ for _, k := range GatewayKeys(s) {
+ seen[k] = true
+ }
for _, id := range s.Copies {
seen[s.Agent+"|"+id] = true
}
diff --git a/internal/sessions/manage.go b/internal/sessions/manage.go
index 5ed451438..c0efe0f36 100644
--- a/internal/sessions/manage.go
+++ b/internal/sessions/manage.go
@@ -70,7 +70,7 @@ type AgentCount struct {
// those kept as files of their own, in a layout magpie knows whole.
func Deletable(agent string) bool {
switch agent {
- case "claude", "qoder", "qoder-cn", "workbuddy", "codebuddy", "codex", "pi", "omp", "cursor", "dsh", "droid":
+ case "claude", "qoder", "qoder-cn", "workbuddy", "codebuddy", "codex", "pi", "raft", "omp", "cursor", "dsh", "droid":
return true
}
return false
@@ -193,7 +193,7 @@ func readFor(want, all []file, quick bool) (pending map[string]bool, done func()
// session's file, not taken from its name (as assemble does).
func idInFile(agent string) bool {
switch agent {
- case "codex", "pi", "omp", "dsh", "grok", "droid":
+ case "codex", "pi", "raft", "omp", "dsh", "grok", "droid":
return true
}
return false
@@ -204,10 +204,12 @@ func nativeIDs(agents map[string]bool, all []file) map[string]map[string]bool {
}
func nativeIDsWith(agents map[string]bool, all []file, quick bool) map[string]map[string]bool {
- groups := byKey(all, func(f *file) bool { return agents[f.agent] })
+ // Raft's Pi sessions are Pi's to the gateway (GatewayKeys)
+ asked := func(agent string) bool { return agents[agent] || agent == "raft" && agents["pi"] }
+ groups := byKey(all, func(f *file) bool { return asked(f.agent) })
var want []file
for _, f := range all {
- if !agents[f.agent] {
+ if !asked(f.agent) {
continue
}
if idInFile(f.agent) {
@@ -221,7 +223,13 @@ func nativeIDsWith(agents map[string]bool, all []file, quick bool) map[string]ma
out[a] = map[string]bool{}
}
for _, fs := range groups {
- out[fs[0].agent][sessionID(fs)] = true
+ id := sessionID(fs)
+ if a := fs[0].agent; agents[a] {
+ out[a][id] = true
+ }
+ if fs[0].agent == "raft" && agents["pi"] {
+ out["pi"][id] = true
+ }
}
return out
}
@@ -494,7 +502,7 @@ func sessionPaths(agent, id string, fs []file) []string {
}
// the folder beside it: a Claude Code session's subagents and
// tool results, an omp session's artifacts
- if agent != "codex" && agent != "pi" {
+ if agent != "codex" && agent != "pi" && agent != "raft" {
if d := strings.TrimSuffix(f.path, ".jsonl"); d != f.path {
if fi, err := os.Stat(d); err == nil && fi.IsDir() {
add(d)
diff --git a/internal/sessions/pi.go b/internal/sessions/pi.go
index 1eb4b3fd5..b708ac316 100644
--- a/internal/sessions/pi.go
+++ b/internal/sessions/pi.go
@@ -77,6 +77,12 @@ func piFilesIn(dir, sessionDir string) []file {
more, _ := filepath.Glob(filepath.Join(d, "*.jsonl"))
paths = append(paths, more...)
}
+ return piNamed("pi", paths)
+}
+
+// piNamed are the Pi session files among paths, <time>_<id>.jsonl, each
+// once, as agent's.
+func piNamed(agent string, paths []string) []file {
var out []file
seen := map[string]bool{}
for _, p := range paths {
@@ -89,7 +95,7 @@ func piFilesIn(dir, sessionDir string) []file {
if !ok || id == "" {
continue
}
- f := file{agent: "pi", key: "pi:" + id, path: p, main: true}
+ f := file{agent: agent, key: agent + ":" + id, path: p, main: true}
if stat(&f) {
out = append(out, f)
}
diff --git a/internal/sessions/raft.go b/internal/sessions/raft.go
new file mode 100644
index 000000000..504c5bfd7
--- /dev/null
+++ b/internal/sessions/raft.go
@@ -0,0 +1,55 @@
+package sessions
+
+import (
+ "os"
+ "path/filepath"
+
+ "github.com/yetone/magpie/internal/appdir"
+)
+
+// Raft (the slock app, raft-computer) runs its agents each in a workspace
+// of its own, <slock>/agents/<agent id>/. Those it runs on Pi keep their
+// sessions there in .pi-sessions/, and those on its built-in runtime (Pi
+// too, with its own agent folder) in .builtin-sessions/: Pi's SDK files,
+// <time>_<session id>.jsonl, all in one folder (PiDriver's
+// buildPiSessionDir, SessionManager.create). They are read as Pi's, as
+// agent "raft". The handoff notes in <slock>/runtime-sessions are not
+// sessions. Raft's Pi reads the user's own Pi agent folder, so one sent
+// through magpie is the gateway's "pi" session of the same id too
+// (GatewayKeys).
+
+// SlockDir is Raft's folder: $SLOCK_HOME, else ~/.slock
+// (%USERPROFILE%\.slock on Windows).
+func SlockDir() string {
+ if d := appdir.Getenv("SLOCK_HOME"); d != "" {
+ if abs, err := filepath.Abs(expandHome(d)); err == nil {
+ return abs
+ }
+ return expandHome(d)
+ }
+ home, _ := os.UserHomeDir()
+ return filepath.Join(home, ".slock")
+}
+
+func raftFiles() []file { return raftFilesIn(SlockDir()) }
+
+// raftFilesIn are the Pi sessions of the agents in a Raft folder.
+func raftFilesIn(dir string) []file {
+ var paths []string
+ for _, sub := range []string{".pi-sessions", ".builtin-sessions"} {
+ more, _ := filepath.Glob(filepath.Join(dir, "agents", "*", sub, "*.jsonl"))
+ paths = append(paths, more...)
+ }
+ return piNamed("raft", paths)
+}
+
+// GatewayKeys are the "agent|id" keys a session's gateway record can
+// carry: its own, and for Raft's, Pi's, as Raft's Pi tells the gateway
+// it is Pi.
+func GatewayKeys(s Session) []string {
+ k := []string{s.Agent + "|" + s.ID}
+ if s.Agent == "raft" {
+ k = append(k, "pi|"+s.ID)
+ }
+ return k
+}
diff --git a/internal/sessions/raft_test.go b/internal/sessions/raft_test.go
new file mode 100644
index 000000000..cd73f6f25
--- /dev/null
+++ b/internal/sessions/raft_test.go
@@ -0,0 +1,238 @@
+package sessions
+
+import (
+ "errors"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+)
+
+// Raft's agents keep their Pi sessions in their own folders under
+// ~/.slock/agents/<agent id>/: .pi-sessions/ for one run on Pi,
+// .builtin-sessions/ for one on Raft's built-in runtime, each Pi's SDK
+// file, <time>_<id>.jsonl, flat (raft-computer 1.0.14's PiDriver,
+// buildPiSessionDir, and BuiltInDriver). No Raft agent here ran on Pi, so
+// the files are Pi's own (testdata/pi-calls, Pi 1.1.0's, and testdata/pi),
+// moved into Raft's folders with their cwd the agent's folder, as Raft
+// starts Pi there. runtime-sessions/ holds Raft's handoff notes, no
+// session.
+const (
+ raftAgentA = "5b1f0c2e-8d3a-4f6b-9c7e-1a2b3c4d5e6f"
+ raftAgentB = "7c2e1d3f-9e4b-4a7c-8d6f-2b3c4d5e6f70"
+ raftParent = "01a1343b-2288-73d4-b1b4-6fb13abf0069"
+ raftFork = "01a1343b-9a0f-7603-b371-4124126b8b05"
+ raftViaUs = "01a1343b-e8a8-704d-b6cd-046b86c5bf00" // its later calls through magpie
+)
+
+// raftSetup puts the sessions in slock's folder, the home's .slock unless
+// slock is given, and gives back the two agents' folders.
+func raftSetup(t *testing.T, slock string) (a, b string) {
+ t.Helper()
+ claude, _ := manageSetup(t)
+ if slock == "" {
+ slock = filepath.Join(filepath.Dir(claude), "home", ".slock")
+ }
+ a, b = filepath.Join(slock, "agents", raftAgentA), filepath.Join(slock, "agents", raftAgentB)
+ put := func(from, dir string) {
+ t.Helper()
+ data, err := os.ReadFile(from)
+ if err != nil {
+ t.Fatal(err)
+ }
+ ws := filepath.Dir(dir)
+ data = []byte(strings.ReplaceAll(string(data), `"cwd":"/work/relay"`, `"cwd":`+jsonString(ws)))
+ data = []byte(strings.ReplaceAll(string(data), `"cwd":"/work/pi"`, `"cwd":`+jsonString(ws)))
+ os.MkdirAll(dir, 0o755)
+ p := filepath.Join(dir, filepath.Base(from))
+ if err := os.WriteFile(p, data, 0o600); err != nil {
+ t.Fatal(err)
+ }
+ old := time.Now().Add(-24 * time.Hour)
+ os.Chtimes(p, old, old)
+ }
+ calls, _ := filepath.Glob(filepath.Join("testdata", "pi-calls", "sessions", "*", "*.jsonl"))
+ if len(calls) != 3 {
+ t.Fatalf("pi-calls: %v", calls)
+ }
+ for _, f := range calls {
+ put(f, filepath.Join(a, ".pi-sessions"))
+ }
+ put(filepath.Join("testdata", "pi", "sessions", "--work-pi--", "2026-09-24T08-00-00-000Z_"+piFirst+".jsonl"), filepath.Join(b, ".builtin-sessions"))
+ // what Raft hands a runtime on, beside the agents: not a session
+ os.MkdirAll(filepath.Join(slock, "runtime-sessions"), 0o755)
+ os.WriteFile(filepath.Join(slock, "runtime-sessions", "pi-"+raftAgentA+".jsonl"), []byte(`{"type":"handoff","text":"carry on"}`+"\n"), 0o600)
+ Reset()
+ return a, b
+}
+
+func TestRaftSessions(t *testing.T) {
+ a, b := raftSetup(t, "")
+ ss := List(0)
+ for _, s := range ss {
+ if s.Agent == "pi" {
+ t.Fatalf("a Raft session listed as Pi's: %+v", s)
+ }
+ }
+ p := find(t, ss, "raft", raftParent)
+ if p.Cwd != a || p.Title != "ping" || p.Resume != "" {
+ t.Fatalf("raft: %+v", p)
+ }
+ // a fork as Pi's: titled as its parent, its own call alone counted
+ if f := find(t, ss, "raft", raftFork); f.Title != "ping" || f.Tokens != (Tokens{Input: 203, Output: 30, CacheRead: 1000}) {
+ t.Fatalf("the fork: %+v", f)
+ }
+ // one on Raft's built-in runtime
+ if bi := find(t, ss, "raft", piFirst); bi.Cwd != b || bi.Title != "Parser refactor" {
+ t.Fatalf("built-in runtime: %+v", bi)
+ }
+ n := 0
+ for _, s := range ss {
+ if s.Agent == "raft" {
+ n++
+ }
+ }
+ if n != 4 {
+ t.Fatalf("%d Raft sessions, want 4 (the handoff note none)", n)
+ }
+
+ // its conversation, the prompts the user typed in
+ if !HasTranscript("raft") {
+ t.Fatal("no transcript for Raft")
+ }
+ tr, err := TranscriptOf(p)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var said []string
+ for _, x := range tr.Parts {
+ if x.Role == "user" && x.Kind == "text" {
+ said = append(said, x.Text)
+ }
+ }
+ if strings.Join(said, "|") != "ping|again" {
+ t.Fatalf("prompts %q in %+v", said, tr.Parts)
+ }
+
+ // its calls are Raft's on the Usage page, those through magpie the
+ // gateway's
+ by, relay := map[string]int{}, 0
+ for _, c := range Calls(time.Time{}) {
+ by[c.Agent]++
+ if c.Agent == "raft" && (c.Upstream == "magpie" || c.Upstream == "dead") {
+ t.Errorf("a call through magpie or one that failed: %+v", c)
+ }
+ if c.Agent == "raft" && (c.Session == raftParent || c.Session == raftFork) && c.Upstream == "relay" && c.Cwd == a {
+ relay++
+ }
+ }
+ if relay != 3 || by["pi"] != 0 {
+ t.Fatalf("Raft's relay calls %d, want 3 (as TestPiCalls); calls by agent %v", relay, by)
+ }
+
+ found := false
+ for _, d := range Dirs() {
+ found = found || d == filepath.Dir(filepath.Dir(a))
+ }
+ if !found {
+ t.Fatalf("Raft's folder not among %v", Dirs())
+ }
+}
+
+// Raft's Pi uses the user's own Pi folder, so one sent through magpie says
+// it is Pi to the gateway under the same id: that is the Raft session, and
+// not listed a second time.
+func TestRaftIsPiToTheGateway(t *testing.T) {
+ raftSetup(t, "")
+ ss := List(0)
+ merged := MergeExternal(ss, []ExternalSession{
+ {Agent: "pi", ID: raftViaUs, Title: "fail"},
+ {Agent: "pi", ID: "01a1343b-0000-7000-8000-000000000000", Title: "Pi's own"},
+ })
+ pis := 0
+ for _, s := range merged {
+ if s.Agent == "pi" {
+ pis++
+ if s.ID == raftViaUs {
+ t.Fatalf("Raft's session listed again as the gateway's Pi one: %+v", s)
+ }
+ }
+ }
+ if pis != 1 {
+ t.Fatalf("Pi's own gateway session: %d listed", pis)
+ }
+ if ids := NativeIDs(map[string]bool{"pi": true})["pi"]; !ids[raftViaUs] || !ids[raftParent] {
+ t.Fatalf("Pi's native ids leave Raft's out: %v", ids)
+ }
+ if ids := NativeIDs(map[string]bool{"raft": true}); !ids["raft"][raftViaUs] || len(ids["pi"]) != 0 {
+ t.Fatalf("Raft's native ids: %v", ids)
+ }
+ _, native := StatsAndNative(0)
+ if !native["raft|"+raftViaUs] || !native["pi|"+raftViaUs] {
+ t.Fatalf("the gateway's Pi session is counted again: %v", native)
+ }
+}
+
+// A Raft session goes to the trash as a Pi one does: its one file, and no
+// folder beside it (the agent's own workspace is not the session's). Raft
+// starts afresh when it finds no file for the id it kept.
+func TestRaftDeleteRestore(t *testing.T) {
+ a, _ := raftSetup(t, "")
+ if !Deletable("raft") {
+ t.Fatal("Raft not deletable")
+ }
+ file := filepath.Join(a, ".pi-sessions", "2026-10-13T07-47-33-129Z_"+raftParent+".jsonl")
+ // a folder named as the file would be is not the session's
+ beside := strings.TrimSuffix(file, ".jsonl")
+ os.MkdirAll(beside, 0o755)
+ os.Chtimes(beside, time.Now().Add(-24*time.Hour), time.Now().Add(-24*time.Hour))
+
+ now := time.Now()
+ os.Chtimes(file, now, now)
+ if _, err := Delete("raft", raftParent); !errors.Is(err, ErrActive) {
+ t.Fatalf("a session just written: %v", err)
+ }
+ old := now.Add(-24 * time.Hour)
+ os.Chtimes(file, old, old)
+
+ tr, err := Delete("raft", raftParent)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(tr.Items) != 1 || tr.Title != "ping" {
+ t.Fatalf("trashed %+v, want the one file", tr)
+ }
+ if _, err := os.Stat(file); err == nil {
+ t.Fatal("the file is still there")
+ }
+ if _, err := os.Stat(beside); err != nil {
+ t.Fatalf("the folder beside it went too: %v", err)
+ }
+ if _, ok := findSession(List(0), "raft", raftParent); ok {
+ t.Fatal("still listed")
+ }
+ if _, err := Restore(tr.Key); err != nil {
+ t.Fatal(err)
+ }
+ Reset()
+ if s, ok := findSession(List(0), "raft", raftParent); !ok || s.Title != "ping" {
+ t.Fatalf("the restored session: %+v", s)
+ }
+}
+
+// $SLOCK_HOME moves Raft's folder, as raft-computer's resolveSlockHome
+// reads it.
+func TestRaftSlockHome(t *testing.T) {
+ other := filepath.Join(t.TempDir(), "slock")
+ raftSetup(t, other)
+ if _, ok := findSession(List(0), "raft", raftParent); ok {
+ t.Fatal("read from ~/.slock with $SLOCK_HOME unset")
+ }
+ t.Setenv("SLOCK_HOME", other)
+ Reset()
+ find(t, List(0), "raft", raftParent)
+ if SlockDir() != other {
+ t.Fatalf("SlockDir %s", SlockDir())
+ }
+}
diff --git a/internal/sessions/sessions.go b/internal/sessions/sessions.go
index 62a860463..d9f4ae8da 100644
--- a/internal/sessions/sessions.go
+++ b/internal/sessions/sessions.go
@@ -625,8 +625,8 @@ func allFiles() []file {
filesHook()
}
var out []file
- for _, fs := range [][]file{callFiles(), openCodeFiles(), piFiles(),
- wslFiles("pi", "omp", "kimi"), zcodeFiles(), dshFiles(), clineFiles(), ccFiles("qoder", QoderDir("qoder")), ccFiles("qoder-cn", QoderDir("qoder-cn")),
+ for _, fs := range [][]file{callFiles(), openCodeFiles(), piFiles(), raftFiles(),
+ wslFiles("pi", "raft", "omp", "kimi"), zcodeFiles(), dshFiles(), clineFiles(), ccFiles("qoder", QoderDir("qoder")), ccFiles("qoder-cn", QoderDir("qoder-cn")),
grokFiles(), workbuddyFiles(), codebuddyFiles(), droidFiles(), ompFiles(), cursorFiles(), hermesFiles(), almaFiles(), kimiFiles(), agyFiles()} {
out = append(out, fs...)
}
@@ -658,6 +658,7 @@ func Dirs() []string {
for _, d := range []struct{ dir, sessions string }{
{OpenCodeDir(), OpenCodeDir()},
{PiDir(), PiDir()},
+ {SlockDir(), filepath.Join(SlockDir(), "agents")},
{ZCodeDir(), zcodeDB()},
{DshDir(), filepath.Join(DshDir(), "sessions")},
{ClineSessionDir(), ClineSessionDir()},
@@ -1644,7 +1645,7 @@ func parserFor(agent string) sessionParser {
return sessionParser{whole: parseCursor}
case "codex":
return sessionParser{line: codexBody}
- case "pi", "omp":
+ case "pi", "raft", "omp":
return sessionParser{line: piParse}
case "workbuddy", "codebuddy":
return sessionParser{line: workbuddyLine}
diff --git a/internal/sessions/stats.go b/internal/sessions/stats.go
index 2b3cb1a24..5d659b38c 100644
--- a/internal/sessions/stats.go
+++ b/internal/sessions/stats.go
@@ -240,7 +240,9 @@ func statsKept(ranges []int, now time.Time, wantNative bool) ([]Stats, map[strin
for key, fs := range groups {
// as List: a session nothing was said in is not listed
if s, ok := assembleListed(fs, price, titles); ok {
- native[s.Agent+"|"+s.ID] = true
+ for _, k := range GatewayKeys(s) {
+ native[k] = true
+ }
listed[key] = s
}
}
diff --git a/internal/sessions/transcript.go b/internal/sessions/transcript.go
index 62074a189..9b228f463 100644
--- a/internal/sessions/transcript.go
+++ b/internal/sessions/transcript.go
@@ -32,7 +32,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", "omp", "cursor", "opencode", "kimi", "agy":
+ case "claude", "qoder", "qoder-cn", "codex", "pi", "raft", "omp", "cursor", "opencode", "kimi", "agy":
return true
}
return false
@@ -87,7 +87,7 @@ func readTranscriptOf(s Session, keep func([]byte) bool, add func(bool, Part) bo
return cursorTranscript(s.Path, add)
case "codex":
return codexContentOf(whole, keep, add)
- case "pi", "omp":
+ case "pi", "raft", "omp":
return piTranscript(s.Path, add)
case "kimi":
return kimiTranscript(s.Path, keep, add)
diff --git a/internal/sessions/wsl.go b/internal/sessions/wsl.go
index e3fd2ee45..b40f24d48 100644
--- a/internal/sessions/wsl.go
+++ b/internal/sessions/wsl.go
@@ -67,6 +67,7 @@ var wslAgents = []struct{ agent, dir string }{
{"claude", ".claude"},
{"codex", ".codex"},
{"pi", filepath.Join(".pi", "agent")},
+ {"raft", ".slock"},
{"omp", filepath.Join(".omp", "agent")},
{"kimi", ".kimi-code"},
}
@@ -83,6 +84,8 @@ func wslScan(home string) []file {
out = append(out, codexFilesIn(dir)...)
case "pi":
out = append(out, piFilesIn(dir, "")...)
+ case "raft":
+ out = append(out, raftFilesIn(dir)...)
case "omp":
out = append(out, ompFilesIn(dir)...)
case "kimi":