fix: Address code review comments

This commit is contained in:
gsxdsm
2026-02-17 23:04:42 -08:00
parent 43c19c70ca
commit dd4c738e91
43 changed files with 1128 additions and 359 deletions

View File

@@ -1,4 +1,4 @@
import { useState, useEffect, useCallback, useMemo } from 'react';
import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
import {
FolderOpen,
Folder,
@@ -70,6 +70,9 @@ export function ProjectFileSelectorDialog({
const [selectedPaths, setSelectedPaths] = useState<Set<string>>(new Set());
const [searchQuery, setSearchQuery] = useState('');
// Ref to track the current request generation; incremented to cancel stale requests
const requestGenRef = useRef(0);
// Track the path segments for breadcrumb navigation
const breadcrumbs = useMemo(() => {
if (!currentRelativePath) return [];
@@ -82,6 +85,11 @@ export function ProjectFileSelectorDialog({
const browseDirectory = useCallback(
async (relativePath?: string) => {
// Increment the generation counter so any previously in-flight request
// knows it has been superseded and should not update state.
const generation = ++requestGenRef.current;
const isCancelled = () => requestGenRef.current !== generation;
setLoading(true);
setError('');
setWarning('');
@@ -93,6 +101,8 @@ export function ProjectFileSelectorDialog({
relativePath: relativePath || '',
});
if (isCancelled()) return;
if (result.success) {
setCurrentRelativePath(result.currentRelativePath);
setParentRelativePath(result.parentRelativePath);
@@ -102,9 +112,12 @@ export function ProjectFileSelectorDialog({
setError(result.error || 'Failed to browse directory');
}
} catch (err) {
if (isCancelled()) return;
setError(err instanceof Error ? err.message : 'Failed to load directory contents');
} finally {
setLoading(false);
if (!isCancelled()) {
setLoading(false);
}
}
},
[projectPath]
@@ -117,6 +130,8 @@ export function ProjectFileSelectorDialog({
setSearchQuery('');
browseDirectory();
} else {
// Invalidate any in-flight request so it won't clobber the cleared state
requestGenRef.current++;
setCurrentRelativePath('');
setParentRelativePath(null);
setEntries([]);

View File

@@ -42,9 +42,9 @@ export function SandboxRiskDialog({ open, onConfirm, onDeny }: SandboxRiskDialog
onEscapeKeyDown={(e) => e.preventDefault()}
showCloseButton={false}
>
<DialogHeader className="flex-shrink-0">
<DialogHeader className="shrink-0">
<DialogTitle className="flex items-center gap-2 text-destructive">
<ShieldAlert className="w-6 h-6 flex-shrink-0" />
<ShieldAlert className="w-6 h-6 shrink-0" />
Sandbox Environment Not Detected
</DialogTitle>
</DialogHeader>
@@ -99,7 +99,7 @@ export function SandboxRiskDialog({ open, onConfirm, onDeny }: SandboxRiskDialog
</DialogDescription>
</div>
<DialogFooter className="flex-col gap-4 sm:flex-col pt-4 flex-shrink-0 border-t border-border mt-4">
<DialogFooter className="flex-col gap-4 sm:flex-col pt-4 shrink-0 border-t border-border mt-4">
<div className="flex items-center space-x-2 self-start">
<Checkbox
id="skip-sandbox-warning"