session alignment: force single main session and openclaw-style agents/main/sessions path

This commit is contained in:
DBT
2026-02-26 02:20:51 +00:00
parent 27e805fac0
commit 2d0ca1d4ce
2 changed files with 4 additions and 22 deletions

View File

@@ -75,7 +75,7 @@ func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers
workspace := cfg.WorkspacePath() workspace := cfg.WorkspacePath()
os.MkdirAll(workspace, 0755) os.MkdirAll(workspace, 0755)
sessionsManager := session.NewSessionManager(filepath.Join(filepath.Dir(cfg.WorkspacePath()), "sessions")) sessionsManager := session.NewSessionManager(filepath.Join(filepath.Dir(cfg.WorkspacePath()), "agents", "main", "sessions"))
toolsRegistry := tools.NewToolRegistry() toolsRegistry := tools.NewToolRegistry()
processManager := tools.NewProcessManager(workspace) processManager := tools.NewProcessManager(workspace)
@@ -442,6 +442,7 @@ func (al *AgentLoop) GetSessionHistory(sessionKey string) []providers.Message {
} }
func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage) (string, error) { func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage) (string, error) {
msg.SessionKey = "main"
unlock := al.lockSessionRun(msg.SessionKey) unlock := al.lockSessionRun(msg.SessionKey)
defer unlock() defer unlock()
// Add message preview to log // Add message preview to log

View File

@@ -881,30 +881,11 @@ func (s *RegistryServer) handleWebUISessions(w http.ResponseWriter, r *http.Requ
http.Error(w, "method not allowed", http.StatusMethodNotAllowed) http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return return
} }
sessionsDir := filepath.Join(filepath.Dir(strings.TrimSpace(s.workspacePath)), "sessions") _ = os.MkdirAll(filepath.Join(filepath.Dir(strings.TrimSpace(s.workspacePath)), "agents", "main", "sessions"), 0755)
entries, err := os.ReadDir(sessionsDir)
if err != nil {
if os.IsNotExist(err) {
_ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "sessions": []interface{}{}})
return
}
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
type item struct { type item struct {
Key string `json:"key"` Key string `json:"key"`
} }
out := make([]item, 0, len(entries)) _ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "sessions": []item{{Key: "main"}}})
for _, e := range entries {
if e.IsDir() {
continue
}
name := e.Name()
if strings.HasSuffix(name, ".json") {
out = append(out, item{Key: strings.TrimSuffix(name, ".json")})
}
}
_ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "sessions": out})
} }
func (s *RegistryServer) handleWebUIMemory(w http.ResponseWriter, r *http.Request) { func (s *RegistryServer) handleWebUIMemory(w http.ResponseWriter, r *http.Request) {