fix rename session and agent

This commit is contained in:
Ollie Agent 2026-08-02 22:16:22 +02:00
parent aa6f444fa5
commit 1f2870dd20
3 changed files with 13 additions and 4 deletions

View File

@ -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)
}

View File

@ -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

View File

@ -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