mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-02-02 14:57:33 +00:00
feat: Enhance session handling by adding cursor support and improving cursor messages order
This commit is contained in:
@@ -351,7 +351,6 @@ router.get('/sessions', async (req, res) => {
|
||||
const cwdId = crypto.createHash('md5').update(projectPath || process.cwd()).digest('hex');
|
||||
const cursorChatsPath = path.join(os.homedir(), '.cursor', 'chats', cwdId);
|
||||
|
||||
console.log(`🔍 Looking for Cursor sessions in: ${cursorChatsPath}`);
|
||||
|
||||
// Check if the directory exists
|
||||
try {
|
||||
@@ -465,7 +464,7 @@ router.get('/sessions', async (req, res) => {
|
||||
// Get the most recent blob for preview
|
||||
const lastBlob = await db.get(`
|
||||
SELECT data FROM blobs
|
||||
ORDER BY id DESC
|
||||
ORDER BY rowid DESC
|
||||
LIMIT 1
|
||||
`);
|
||||
|
||||
@@ -593,9 +592,10 @@ router.get('/sessions/:sessionId', async (req, res) => {
|
||||
});
|
||||
|
||||
// Get all blobs (conversation data)
|
||||
// Use rowid for chronological ordering (it's an auto-incrementing integer)
|
||||
const blobs = await db.all(`
|
||||
SELECT id, data FROM blobs
|
||||
ORDER BY id ASC
|
||||
SELECT rowid, id, data FROM blobs
|
||||
ORDER BY rowid ASC
|
||||
`);
|
||||
|
||||
// Get metadata from meta table
|
||||
@@ -659,7 +659,11 @@ router.get('/sessions/:sessionId', async (req, res) => {
|
||||
if (role === 'system') {
|
||||
continue; // Skip only system messages
|
||||
}
|
||||
messages.push({ id: blob.id, content: parsed });
|
||||
messages.push({
|
||||
id: blob.id,
|
||||
rowid: blob.rowid,
|
||||
content: parsed
|
||||
});
|
||||
}
|
||||
// Skip non-JSON blobs (binary data) completely
|
||||
} catch (e) {
|
||||
|
||||
@@ -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 || '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user