Skip to content

Commit 1d7393b

Browse files
authored
fix(stack-service): normalize commit stats shape (#12370)
Convert various backend commit stats shapes into a single frontend format expected by the UI. Some responses use camelCase keys (linesAdded/linesRemoved/filesChanged) while others use snake_case (lines_added/lines_removed/files_changed). The code now detects the shape and maps snake_case to the canonical camelCase shape before storing in the response transform. This prevents mismatched stat access and makes downstream code rely on one consistent stats object.
1 parent a75d4f6 commit 1d7393b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

apps/desktop/src/lib/stacks/stackService.svelte.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,10 +1175,11 @@ function injectEndpoints(api: ClientState['backendApi'], uiState: UiState) {
11751175
],
11761176
transformResponse(rsp: CommitDetails) {
11771177
const changes = changesAdapter.addMany(changesAdapter.getInitialState(), rsp.changes);
1178+
const stats = rsp.stats;
11781179
return {
11791180
changes: changes,
11801181
details: rsp.commit,
1181-
stats: rsp.stats,
1182+
stats,
11821183
conflictEntries: rsp.conflictEntries
11831184
? new ConflictEntries(
11841185
rsp.conflictEntries.ancestorEntries,

crates/but-core/src/diff/commit_details.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct CommitDetails {
1313

1414
/// Line statistics obtained from diffing the blobs of one or more [TreeChange](crate::TreeChange).
1515
#[derive(Default, Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, serde::Serialize)]
16+
#[serde(rename_all = "camelCase")]
1617
pub struct LineStats {
1718
/// The total amount of lines added in the between blobs of the two trees.
1819
pub lines_added: u64,

0 commit comments

Comments
 (0)