feat: Enhance session handling by adding cursor support and improving cursor messages order

This commit is contained in:
simos
2025-08-12 13:43:36 +03:00
parent cd6e5befb8
commit 3e7e60a3a8
7 changed files with 51 additions and 24 deletions

View File

@@ -56,7 +56,6 @@ router.get('/status', async (req, res) => {
try {
const projectPath = await getActualProjectPath(project);
console.log('Git status for project:', project, '-> path:', projectPath);
// Validate git repository
await validateGitRepository(projectPath);
@@ -136,13 +135,16 @@ router.get('/diff', async (req, res) => {
lines.map(line => `+${line}`).join('\n');
} else {
// Get diff for tracked files
const { stdout } = await execAsync(`git diff HEAD -- "${file}"`, { cwd: projectPath });
diff = stdout || '';
// First check for unstaged changes (working tree vs index)
const { stdout: unstagedDiff } = await execAsync(`git diff -- "${file}"`, { cwd: projectPath });
// If no unstaged changes, check for staged changes
if (!diff) {
if (unstagedDiff) {
// Show unstaged changes if they exist
diff = unstagedDiff;
} else {
// If no unstaged changes, check for staged changes (index vs HEAD)
const { stdout: stagedDiff } = await execAsync(`git diff --cached -- "${file}"`, { cwd: projectPath });
diff = stagedDiff;
diff = stagedDiff || '';
}
}