diff options
| author | Fuwn <[email protected]> | 2026-01-30 08:47:29 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-30 08:47:29 +0000 |
| commit | 75fa492c7268b02ef3586d97c40121c791f60f7f (patch) | |
| tree | d46a2c05f53ecbc986a971c3504b40f8cc16a8d3 /internal/claude | |
| parent | feat(claude:session): Support orphaned sessions (diff) | |
| download | faustus-75fa492c7268b02ef3586d97c40121c791f60f7f.tar.xz faustus-75fa492c7268b02ef3586d97c40121c791f60f7f.zip | |
fix: improve orphaned session handling
Diffstat (limited to 'internal/claude')
| -rw-r--r-- | internal/claude/session.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/internal/claude/session.go b/internal/claude/session.go index 0a69cf1..e4999ae 100644 --- a/internal/claude/session.go +++ b/internal/claude/session.go @@ -136,12 +136,12 @@ func loadSessionsFromIndex(indexPath, projectDirectoryName string, inTrash bool) } type jsonlFirstLine struct { - SessionID string `json:"sessionId"` - Cwd string `json:"cwd"` - GitBranch string `json:"gitBranch"` - Timestamp time.Time `json:"timestamp"` - IsSidechain bool `json:"isSidechain"` - Message struct { + SessionID string `json:"sessionId"` + Cwd string `json:"cwd"` + GitBranch string `json:"gitBranch"` + Timestamp time.Time `json:"timestamp"` + IsSidechain bool `json:"isSidechain"` + Message struct { Role string `json:"role"` Content any `json:"content"` } `json:"message"` @@ -355,6 +355,11 @@ func RestoreFromTrash(session *Session) error { sourceProjectDirectory := ProjectDir(session) projectDirectoryName := filepath.Base(sourceProjectDirectory) destinationProjectDirectory := filepath.Join(ProjectsDir(), projectDirectoryName) + + if mkdirError := os.MkdirAll(destinationProjectDirectory, 0o755); mkdirError != nil { + return mkdirError + } + sourceFile := session.FullPath destinationFile := filepath.Join(destinationProjectDirectory, session.SessionID+".jsonl") @@ -435,6 +440,10 @@ func removeFromIndex(projectDirectory, sessionID string) error { fileData, readError := os.ReadFile(indexPath) if readError != nil { + if os.IsNotExist(readError) { + return nil + } + return readError } |