aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-30 08:47:29 +0000
committerFuwn <[email protected]>2026-01-30 08:47:29 +0000
commit75fa492c7268b02ef3586d97c40121c791f60f7f (patch)
treed46a2c05f53ecbc986a971c3504b40f8cc16a8d3
parentfeat(claude:session): Support orphaned sessions (diff)
downloadfaustus-75fa492c7268b02ef3586d97c40121c791f60f7f.tar.xz
faustus-75fa492c7268b02ef3586d97c40121c791f60f7f.zip
fix: improve orphaned session handling
-rw-r--r--internal/app/state.go15
-rw-r--r--internal/app/update.go1
-rw-r--r--internal/claude/session.go21
3 files changed, 27 insertions, 10 deletions
diff --git a/internal/app/state.go b/internal/app/state.go
index 82e186d..cebd672 100644
--- a/internal/app/state.go
+++ b/internal/app/state.go
@@ -72,10 +72,19 @@ func (m *Model) updateFilteredFromOriginal() {
func (m *Model) reloadSessions() {
sessions, loadError := claude.LoadAllSessions()
- if loadError == nil {
- m.sessions = sessions
+ if loadError != nil {
+ m.setMessage("Reload error: " + loadError.Error())
- m.updateFiltered()
+ return
+ }
+
+ m.sessions = sessions
+
+ m.updateFiltered()
+ m.invalidatePreviewCache()
+
+ if m.cursor >= len(m.filtered) {
+ m.cursor = max(0, len(m.filtered)-1)
}
}
diff --git a/internal/app/update.go b/internal/app/update.go
index b50fe82..7e8409e 100644
--- a/internal/app/update.go
+++ b/internal/app/update.go
@@ -404,7 +404,6 @@ func (m Model) executeConfirmedAction() (tea.Model, tea.Cmd) {
if deleteError := claude.MoveToTrash(session); deleteError != nil {
m.setMessage(fmt.Sprintf("Error: %v", deleteError))
} else {
- m.setMessage("Moved to Bin")
m.reloadSessions()
}
}
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
}