feat: Add auto-refresh for file tree with configurable interval#14
feat: Add auto-refresh for file tree with configurable interval#14pedramamini wants to merge 1 commit intomainfrom
Conversation
- Add fileTreeRefreshInterval setting (3s to 5min range, default 3s) - Add slider UI in Settings modal under General section - Implement auto-refresh logic in FileExplorerPanel that: - Only runs when Files tab is active - Uses debouncing to prevent overlapping refreshes - Respects user-configured refresh interval - Manual refresh button remains available for immediate updates Resolves #11 Co-authored-by: Pedram Amini <pedramamini@users.noreply.github.com>
Code Review✅ Overall AssessmentThis is a well-implemented feature that follows the repository's coding conventions and patterns. The implementation is clean, properly structured, and addresses a real need for auto-refreshing file trees. Good work! 🎯 Strengths
🐛 Potential Issues1. Missing dependency cleanup (FileExplorerPanel.tsx:110)The Recommendation: // In App.tsx, wrap refreshFileTree with useCallback
const refreshFileTree = useCallback(async (sessionId: string) => {
// ... existing implementation
}, [/* stable dependencies */]);Or handle it locally: const refreshFileTreeRef = useRef(refreshFileTree);
refreshFileTreeRef.current = refreshFileTree;
useEffect(() => {
if (activeRightTab !== 'files') return;
const intervalMs = fileTreeRefreshInterval * 1000;
const intervalId = setInterval(async () => {
if (refreshInProgressRef.current) return;
try {
refreshInProgressRef.current = true;
await refreshFileTreeRef.current(session.id);
} catch (error) {
console.error('Auto-refresh failed:', error);
} finally {
refreshInProgressRef.current = false;
}
}, intervalMs);
return () => clearInterval(intervalId);
}, [activeRightTab, fileTreeRefreshInterval, session.id]);2. Race condition on rapid interval changesIf a user rapidly adjusts the slider, the old interval keeps running until the next execution cycle, potentially causing a refresh burst. Current flow:
Recommendation: Add early return check: const activeIntervalRef = useRef<NodeJS.Timeout | null>(null);
useEffect(() => {
if (activeRightTab !== 'files') return;
const intervalMs = fileTreeRefreshInterval * 1000;
const intervalId = setInterval(async () => {
if (refreshInProgressRef.current) return;
if (activeIntervalRef.current !== intervalId) return; // Added: prevent stale callbacks
try {
refreshInProgressRef.current = true;
await refreshFileTree(session.id);
} catch (error) {
console.error('Auto-refresh failed:', error);
} finally {
refreshInProgressRef.current = false;
}
}, intervalMs);
activeIntervalRef.current = intervalId;
return () => {
clearInterval(intervalId);
if (activeIntervalRef.current === intervalId) {
activeIntervalRef.current = null;
}
};
}, [activeRightTab, fileTreeRefreshInterval, session.id, refreshFileTree]);🔒 Security Considerations✅ No security issues detected
⚡ Performance Considerations
🧪 Test CoverageNo tests present - The repository has no test infrastructure ( Recommendation for future: Consider adding integration tests for:
📝 Minor Suggestions
🎉 SummaryThis PR is ready to merge with minor considerations. The implementation is solid and follows best practices. The identified issues are edge cases that may or may not manifest in practice. Priority fixes:
Nice-to-haves:
Great work implementing this feature! The debouncing logic and tab-awareness show thoughtful design. 🚀 |
|
Figured out a good way of doing this for now. WIll be included in next release. |
Summary
Implements auto-refresh for the Files tab in the right panel with a configurable interval setting.
Changes
fileTreeRefreshIntervalsetting (3s to 5min range, default 3s)Testing
Closes #11
Generated with Claude Code