Highlight current-folder sessions in resume browser

This commit is contained in:
Dmitry Lyalin
2026-02-12 23:51:08 -05:00
parent 0806784b90
commit d166645107

View File

@@ -7,6 +7,7 @@
import type React from 'react';
import { useState, useCallback, useMemo, useEffect } from 'react';
import { Box, Text } from 'ink';
import path from 'node:path';
import { Colors } from '../colors.js';
import { useTerminalSize } from '../hooks/useTerminalSize.js';
import { useKeypress } from '../hooks/useKeypress.js';
@@ -419,6 +420,18 @@ const formatTimestamp = (timestamp: string): string => {
return parsed.toLocaleString();
};
const isSessionFromCurrentFolder = (projectRoot?: string): boolean => {
if (!projectRoot) {
return false;
}
try {
return path.resolve(projectRoot) === path.resolve(process.cwd());
} catch {
return false;
}
};
const SessionDetailsPanel = ({
session,
}: {
@@ -505,11 +518,13 @@ const SessionItem = ({
state.startIndex + state.visibleSessions.indexOf(session);
const isActive = originalIndex === state.activeIndex;
const isDisabled = session.isCurrentSession;
const isCurrentFolder = isSessionFromCurrentFolder(session.projectRoot);
const activeColor = isCurrentFolder ? Colors.AccentCyan : Colors.AccentPurple;
const textColor = (c: string = Colors.Foreground) => {
if (isDisabled) {
return Colors.Gray;
}
return isActive ? Colors.AccentPurple : c;
return isActive ? activeColor : c;
};
const prefix = isActive ? ' ' : ' ';