Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/kotlin/com/gitvantage/app/AppState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,7 @@ class AppState(private val scope: CoroutineScope) {
val vms = views()
return mapOf(
"all" to vms.size,
"dirty" to vms.count { it.isDirty },
"dirty" to vms.count { it.dirtyAnywhere },
"aging" to vms.count { it.aging },
"unpushed" to vms.count { it.ahead > 0 },
"behind" to vms.count { it.repo.behind > 0 },
Expand Down Expand Up @@ -2803,7 +2803,7 @@ class AppState(private val scope: CoroutineScope) {
entries[id]?.addedAt?.let { System.currentTimeMillis() - it.toEpochMilli() < Meta.RECENT_MS } ?: false

private fun statusPredicate(v: RepoView): Boolean = when (status) {
"dirty" -> v.isDirty
"dirty" -> v.dirtyAnywhere
"aging" -> v.aging
"unpushed" -> v.ahead > 0
"behind" -> v.repo.behind > 0
Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/com/gitvantage/app/Derive.kt
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ data class RepoView(
* [Repo.worktreesUnlanded] counts folders; this counts the ones still allowed to speak up.
*/
val worktreesUnlanded get() = worktrees.count { it.rollsUp }

/**
* Uncommitted changes in this checkout or in any of its linked worktrees — what the Dirty
* filter selects. Kept apart from [isDirty], which stays about this checkout alone because it
* drives the row's badges and its Commit button, and neither of those can act on another folder.
* Read raw like [isDirty]: a snooze silences alerts, it doesn't make a tree clean.
*/
val dirtyAnywhere get() = isDirty || worktrees.any { it.wt.dirtyCount > 0 }
}

/** Contextual primary action pill. */
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/gitvantage/ui/Bars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ fun StatusBar(state: AppState) {
// key, label, and the hover explanation of what the filter selects.
val chips = listOf(
Triple("all", "All", "Every tracked repository."),
Triple("dirty", "Dirty", "Repos with uncommitted changes — staged, modified, or untracked files."),
Triple("dirty", "Dirty", "Repos with uncommitted changes — staged, modified, or untracked files — in the main checkout or any of its worktrees."),
Triple("aging", "Aging", "Repos whose uncommitted changes have been sitting for over 24 hours."),
Triple("unpushed", "Unpushed", "Repos with local commits that haven't been pushed to their upstream yet."),
Triple("behind", "Behind", "Repos whose branch is behind its upstream — there are commits to pull in."),
Expand Down
55 changes: 55 additions & 0 deletions src/test/kotlin/com/gitvantage/app/DirtyFilterTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-FileCopyrightText: 2026 Raman Gupta
// SPDX-License-Identifier: GPL-3.0-or-later

package com.gitvantage.app

import androidx.compose.ui.graphics.Color
import com.gitvantage.model.Repo
import com.gitvantage.model.Worktree
import com.gitvantage.model.WorktreeAlerts
import de.infix.testBalloon.framework.core.testSuite

/**
* What the Dirty filter selects: uncommitted work in the repo's own checkout *or* in any of its
* linked worktrees — while the row's own [RepoView.isDirty], which drives its badges and Commit
* button, stays about the checkout the row stands for.
*/
val DirtyFilter by testSuite {

fun tree(dirty: Int) = Worktree(
path = "/w/side", head = "abc1234", branch = "side", bare = false,
locked = false, lockReason = null, prunable = false, prunableReason = null,
isMain = false, dirtyCount = dirty,
)

fun view(unstaged: Int = 0, treeDirty: Int? = null, treeSnoozed: Boolean = false) = deriveView(
Repo(id = "/w", name = "w", branch = "main", unstaged = unstaged),
Color.Unspecified, emptyList(),
worktrees = listOfNotNull(treeDirty?.let {
WorktreeView(
wt = tree(it), repoId = "/w", alerts = WorktreeAlerts(),
snoozed = treeSnoozed, snoozedFor = if (treeSnoozed) "2d" else null, parentAlertsOn = true,
)
}),
)

test("a clean checkout with a dirty worktree is dirty for the filter, not for the row") {
val v = view(treeDirty = 3)
assert(v.dirtyAnywhere)
assert(!v.isDirty)
}

test("a dirty checkout is dirty either way") {
assert(view(unstaged = 1).dirtyAnywhere)
assert(view(unstaged = 1, treeDirty = 0).dirtyAnywhere)
}

test("clean everywhere stays out of the filter") {
assert(!view().dirtyAnywhere)
assert(!view(treeDirty = 0).dirtyAnywhere)
}

test("a snoozed worktree still counts — a snooze doesn't make a tree clean") {
assert(view(treeDirty = 2, treeSnoozed = true).dirtyAnywhere)
}
}
Loading