{"record":{"id":"384286872f89c6e0","repo":"charmbracelet/crush","slug":"no-sessions-found-to-continue-384286","errorCode":null,"errorMessage":"no sessions found to continue","messagePattern":"no sessions found to continue","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/run.go","lineNumber":687,"sourceCode":"// If continueSessionID is set it fetches that session; if useLast is set it\n// returns the most recently updated top-level session; otherwise it creates a\n// new one.\nfunc resolveSession(ctx context.Context, c *client.Client, wsID, continueSessionID string, useLast bool) (*proto.Session, error) {\n\tswitch {\n\tcase continueSessionID != \"\":\n\t\tsess, err := c.GetSession(ctx, wsID, continueSessionID)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"session not found: %s\", continueSessionID)\n\t\t}\n\t\tif sess.ParentSessionID != \"\" {\n\t\t\treturn nil, fmt.Errorf(\"cannot continue a child session: %s\", continueSessionID)\n\t\t}\n\t\treturn sess, nil\n\n\tcase useLast:\n\t\tsessions, err := c.ListSessions(ctx, wsID)\n\t\tif err != nil || len(sessions) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"no sessions found to continue\")\n\t\t}\n\t\tlast := sessions[0]\n\t\tfor _, s := range sessions[1:] {\n\t\t\tif s.UpdatedAt > last.UpdatedAt && s.ParentSessionID == \"\" {\n\t\t\t\tlast = s\n\t\t\t}\n\t\t}\n\t\treturn &last, nil\n\n\tdefault:\n\t\treturn c.CreateSession(ctx, wsID, \"non-interactive\")\n\t}\n}\n\n// resolveSessionByID resolves a session ID that may be a full UUID or a hash\n// prefix returned by crush session list.\nfunc resolveSessionByID(ctx context.Context, c *client.Client, wsID, id string) (*proto.Session, error) {\n\tif sess, err := c.GetSession(ctx, wsID, id); err == nil {","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/run.go#L669-L705","documentation":"When --continue is used without an ID (useLast), resolveSession calls client.ListSessions and fails if the listing errors or returns zero sessions. Both conditions collapse into this one message, so an empty workspace and an RPC failure look identical to the user.","triggerScenarios":"Running `crush run --continue \"prompt\"` (continue-last behavior) in a workspace that has never had a session, after the DB was wiped/moved, or when ListSessions fails due to server/connection issues.","commonSituations":"First-ever run with --continue; pointing --data-dir at an empty directory; CI environment with a fresh HOME so the global config/cache dir has no sessions; server unreachable.","solutions":["Omit --continue so a new session is created automatically.","Run an interactive `crush` session once (or any successful run) to create a session, then use --continue.","Ensure --data-dir / HOME point at the directory that actually holds your sessions.","If sessions should exist, check the server is up and the DB file is readable."],"exampleFix":"// before\ncrush run --continue \"do the thing\"   # no sessions yet\n// after\ncrush run \"do the thing\"              # creates a new session","handlingStrategy":"validation","validationCode":"sessions, err := c.ListSessions(ctx, wsID)\nif err != nil || len(sessions) == 0 {\n    // no sessions yet — don't pass --continue\n    fmt.Println(\"no sessions exist; starting fresh\")\n}","typeGuard":"func hasContinuableSession(sessions []proto.Session) bool {\n    for _, s := range sessions {\n        if s.ParentSessionID == \"\" {\n            return true\n        }\n    }\n    return false\n}","tryCatchPattern":"out, err := runCrush(\"run\", maybeContinueFlag, prompt)\nif err != nil && strings.Contains(out, \"no sessions found to continue\") {\n    out, err = runCrush(\"run\", prompt) // fresh session\n}","preventionTips":["Check for existing sessions before adding --continue in scripts/CI.","Ensure HOME/--data-dir is persisted between CI runs if you rely on --continue.","Run at least one successful session before using --continue."],"tags":["cli","session","empty-state"],"backgroundTag":"no-sessions-to-continue","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}