feat: Redesign git changes to split stage/unstaged files. (#1359)

* feat: Redesign git changes to split stage/unstaged files.

Signed-off-by: Paolo Insogna <paolo@cowtech.it>

* fixup

Signed-off-by: Paolo Insogna <paolo@cowtech.it>

* fixup

Signed-off-by: Paolo Insogna <paolo@cowtech.it>

* refactor: streamline git changes panel

* fix: label staged and working diff tabs

* fix: isolate staged and working diff files

* fix: scope staged and working diff updates

* fix: scope git row revert to working changes

---------

Signed-off-by: Paolo Insogna <paolo@cowtech.it>
Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
Paolo Insogna
2026-05-24 00:49:38 +03:00
committed by GitHub
co-authored by Bohdan Triapitsyn
parent 9af0de0056
commit e16097b05d
42 changed files with 2987 additions and 923 deletions
@@ -97,11 +97,12 @@ export const PendingChangesBar: React.FC = React.memo(() => {
}
const store = useUIStore.getState();
const openStagedDiff = file.hasStagedChanges && !file.hasWorkingChanges;
if (!store.isMobile) {
store.openContextDiff(currentDirectory, file.relativePath);
store.openContextDiff(currentDirectory, file.relativePath, openStagedDiff);
return;
}
store.navigateToDiff(file.relativePath);
store.navigateToDiff(file.relativePath, openStagedDiff);
store.setRightSidebarOpen(false);
};
@@ -16,6 +16,8 @@ export interface GitChangedFile {
insertions: number;
deletions: number;
status: string;
hasStagedChanges: boolean;
hasWorkingChanges: boolean;
}
export type ChangedFileEntry = ChangedFile | GitChangedFile;
@@ -153,8 +155,12 @@ export const extractGitChangedFiles = (
): GitChangedFile[] => {
const result: GitChangedFile[] = [];
for (const file of files) {
const code = file.working_dir !== ' ' ? file.working_dir : file.index;
if (code === '!' || code === ' ') continue;
const indexStatus = file.index?.trim() ?? '';
const workingStatus = file.working_dir?.trim() ?? '';
const hasStagedChanges = Boolean(indexStatus && indexStatus !== '?');
const hasWorkingChanges = Boolean(workingStatus || indexStatus === '?');
const code = workingStatus || indexStatus;
if (!code || code === '!') continue;
const stats = diffStats?.[file.path];
result.push({
path: file.path.startsWith('/') ? file.path : (directory.endsWith('/') ? directory : directory + '/') + file.path,
@@ -162,6 +168,8 @@ export const extractGitChangedFiles = (
insertions: stats?.insertions ?? 0,
deletions: stats?.deletions ?? 0,
status: code,
hasStagedChanges,
hasWorkingChanges,
});
}
return result;