From 1f2870dd202512caa402946502820a6af163459f Mon Sep 17 00:00:00 2001 From: Ollie Agent Date: Sun, 2 Aug 2026 22:16:22 +0200 Subject: [PATCH] fix rename session and agent --- cmd/ollie-9p/main.go | 10 +++++++--- fs/agentfiles.go | 4 +++- fs/sessionfiles.go | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cmd/ollie-9p/main.go b/cmd/ollie-9p/main.go index 28b5b5f..83c1a0d 100644 --- a/cmd/ollie-9p/main.go +++ b/cmd/ollie-9p/main.go @@ -355,14 +355,18 @@ func modeString(mode plan9.Perm) string { func cmdMv(oldPath, newPath string) { fsys := dial() - // 9P Twstat renames within the parent directory. The new name must be - // just the leaf name, not a full path. Validate that both arguments - // are full paths under the same parent. + // Twstat takes a destination basename. Both paths must refer to the + // same directory; normalize redundant trailing slashes before comparing. + oldPath = strings.TrimRight(oldPath, "/") + newPath = strings.TrimRight(newPath, "/") oldParent, _ := splitPath(oldPath) newParent, newLeaf := splitPath(newPath) if oldParent != newParent { fatalf("mv: old and new paths must be in the same directory (%s != %s)", oldParent, newParent) } + if newLeaf == "" || newLeaf == "." || newLeaf == ".." { + fatalf("mv: invalid destination %q", newPath) + } if err := fsys.Wstat(oldPath, &plan9.Dir{Name: newLeaf}); err != nil { fatalf("mv %s %s: %v", oldPath, newPath, err) } diff --git a/fs/agentfiles.go b/fs/agentfiles.go index 99551f2..6afe4f2 100644 --- a/fs/agentfiles.go +++ b/fs/agentfiles.go @@ -27,7 +27,9 @@ func listAgents(ctx HandlerCtx) ([]FsNodeDecl, error) { continue } - dirName := a.ID() + // The namespace uses the mutable agent name. The immutable ID remains + // available through the id file and is used for the log map. + dirName := a.Name() agentDir := Dir(dirName, // prompt — submit a prompt to the agent diff --git a/fs/sessionfiles.go b/fs/sessionfiles.go index 5a58a8e..8f69a2b 100644 --- a/fs/sessionfiles.go +++ b/fs/sessionfiles.go @@ -132,6 +132,9 @@ func listSessions(ctx HandlerCtx) ([]FsNodeDecl, error) { }), ), ) + // Dynamic session directories must expose the lifecycle rename operation. + // Without this, Tree.Rename finds the directory but reports “rename not supported”. + sessionDir.Rename = func(newName string) error { return rename(newName) } out = append(out, sessionDir) } return out, nil