fix(sessions): send profile in destructive bodies and prune the asked window (#1398)

Co-authored-by: M57 <41645758+Hy4ri@users.noreply.github.com>
This commit is contained in:
Nikhil NairandM57 authored and GitHub committed 2026-09-30 11:27:40 +03:00
1 parent 012440b8f7
commit 7a2822fade
9 files changed
+107 -4

No files matched your search

@@ -66,6 +66,7 @@ import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.FilterChip
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
@@ -507,6 +508,24 @@ fun SessionsScreen(
// (The scaffold already applies top-bar padding via its inner Box, so we
// must NOT re-apply paddingValues here.)
Column(modifier = Modifier.fillMaxSize()) {
// Prune can take a while on large histories — show it's working.
if (state.isPruning) {
Column(
modifier =
Modifier
.fillMaxWidth()
.padding(horizontal = spacing.md, vertical = spacing.sm)
.testTag("sessions_pruning_indicator"),
verticalArrangement = Arrangement.spacedBy(spacing.xs),
) {
Text(
text = stringResource(R.string.sessions_pruning),
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
}
}
Row(
modifier =
Modifier
@@ -963,7 +963,13 @@ class SessionsViewModel(
val result =
safeApiCall {
ApiClient.hermesApi.bulkDeleteSessions(
body = BulkDeleteRequest(ids = ids),
body =
BulkDeleteRequest(
ids = ids,
// Destructive POSTs scope by BODY profile; the
// ?profile= query rewrite never reaches them.
profile = AuthManager.activeProfileId.value,
),
)
}
when (result) {
@@ -1021,7 +1027,16 @@ class SessionsViewModel(
val result =
safeApiCall {
ApiClient.hermesApi.pruneSessions(
body = PruneRequest(days = days),
body =
PruneRequest(
// The server model is `older_than_days`; the
// old `days` key was silently ignored and the
// backend pruned its own 90-day default.
olderThanDays = days,
// Destructive POSTs scope by BODY profile; the
// ?profile= query rewrite never reaches them.
profile = AuthManager.activeProfileId.value,
),
)
}
when (result) {