Skip to content

Commit 26899ef

Browse files
yepzdkclaude
andcommitted
Skip empty log files and add desktop session indicator
- Skip sessions with empty log files (common with desktop app) - Add IsDesktop field to identify home-directory sessions - Show subtle [D] indicator for desktop app sessions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 05ca4ad commit 26899ef

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

internal/session/session.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type Session struct {
3333
LastMessage string `json:"last_message,omitempty"`
3434
LogFile string `json:"-"`
3535
ProjectPath string `json:"-"` // Full path to the project directory
36+
IsDesktop bool `json:"is_desktop,omitempty"` // True if session appears to be from desktop app
3637
}
3738

3839
// LogEntry represents a single line in the JSONL log
@@ -109,6 +110,22 @@ func encodeProjectPath(path string) string {
109110
return strings.ReplaceAll(path, "/", "-")
110111
}
111112

113+
// isDesktopSession checks if the project path appears to be from the desktop app
114+
// Desktop app sessions typically have cwd at the home directory (e.g., -Users-username)
115+
func isDesktopSession(projectName string) bool {
116+
// Remove leading dash
117+
name := strings.TrimPrefix(projectName, "-")
118+
parts := strings.Split(name, "-")
119+
120+
// Desktop sessions are typically just home directory: Users-username (2 parts)
121+
// or Users-username- with trailing dash (still 2 meaningful parts)
122+
if len(parts) <= 2 && len(parts) >= 1 && parts[0] == "Users" {
123+
return true
124+
}
125+
126+
return false
127+
}
128+
112129
// Discover finds all active Claude sessions
113130
func Discover() ([]Session, error) {
114131
projectsDir := ClaudeProjectsDir()
@@ -208,6 +225,11 @@ func findMostRecentLog(dir string) (string, error) {
208225
continue
209226
}
210227

228+
// Skip empty log files (often from desktop app)
229+
if info.Size() == 0 {
230+
continue
231+
}
232+
211233
if info.ModTime().After(mostRecentTime) {
212234
mostRecentTime = info.ModTime()
213235
mostRecent = filePath
@@ -224,6 +246,7 @@ func parseSession(projectName, logFile string, runningDirs map[string]bool) (Ses
224246
LogFile: logFile,
225247
Status: StatusInactive, // Default to inactive
226248
ProjectPath: projectName, // Store the encoded name for matching
249+
IsDesktop: isDesktopSession(projectName),
227250
}
228251

229252
// Check if Claude is running in this project directory

internal/ui/ui.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func RenderList(sessions []session.Session) {
5454

5555
fmt.Printf("%s%s %-13s%s %-35s %-15s %s\n",
5656
color, symbol, s.Status, Reset,
57-
truncate(s.Project, 35),
57+
formatProject(s, 35),
5858
elapsed,
5959
truncate(desc, 40))
6060
}
@@ -115,7 +115,7 @@ func RenderLive(sessions []session.Session) {
115115

116116
fmt.Printf("%s%s %-13s%s %-35s %-15s %s\n",
117117
color, symbol, s.Status, Reset,
118-
truncate(s.Project, 35),
118+
formatProject(s, 35),
119119
elapsed,
120120
truncate(desc, 35))
121121
}
@@ -235,3 +235,16 @@ func truncate(s string, max int) string {
235235
}
236236
return s[:max-3] + "..."
237237
}
238+
239+
// formatProject formats the project name with optional desktop indicator
240+
func formatProject(s session.Session, maxLen int) string {
241+
name := s.Project
242+
if s.IsDesktop {
243+
// Add subtle desktop indicator
244+
indicator := Dim + " [D]" + Reset
245+
// Account for indicator in truncation (4 visible chars)
246+
truncated := truncate(name, maxLen-4)
247+
return truncated + indicator
248+
}
249+
return truncate(name, maxLen)
250+
}

0 commit comments

Comments
 (0)