Skip to content

Commit e076590

Browse files
committed
address review (codex): debounce inline Python path input, gate arch warning to darwin/arm64
* LocalSetupPanel: the inline path input fired onPythonPathChange on every keystroke. In the VideoGen consumer that meant a settings PATCH + a ~1-2s status re-probe per character. Decouple via local draft state; commit on 800ms debounce or onBlur. Programmatic updates (Detect, Switch-to-arm64, Create-venv) still call onPythonPathChange directly so they take effect immediately. * /api/image-gen/setup/check: generic interpreterArch !== HOST_ARCH would false-positive on Windows (Python reports `AMD64` vs Node's `x86_64`) and on hypothetical arm64 Linux where mlx isn't even in REQUIRED_PACKAGES. Gate the warning to darwin/arm64 with an x86_64 interpreter — the only configuration where mlx actually breaks. The third codex finding (hfDownload.js falls back to broken FLUX.2 venv) is in a file not yet on origin and not part of this PR's surface; left for whichever branch ships hfDownload.
1 parent df500e9 commit e076590

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

client/src/components/settings/LocalSetupPanel.jsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ export default function LocalSetupPanel({ pythonPath, onPythonPathChange, onPack
1212
const [creatingVenv, setCreatingVenv] = useState(false);
1313
const logRef = useRef(null);
1414
const installEsRef = useRef(null);
15+
// Decouple the input from the parent's persisted path. The VideoGen
16+
// consumer saves on every onPythonPathChange, so wiring the input to the
17+
// prop directly fires a settings PATCH + ~1-2s status re-probe per
18+
// keystroke. Typed edits commit on debounce/blur; programmatic updates
19+
// (Detect, Switch-to-arm64, Create-venv) still call onPythonPathChange
20+
// directly so they take effect immediately.
21+
const [draftPath, setDraftPath] = useState(pythonPath || '');
22+
const commitTimerRef = useRef(null);
23+
useEffect(() => { setDraftPath(pythonPath || ''); }, [pythonPath]);
24+
useEffect(() => () => clearTimeout(commitTimerRef.current), []);
25+
const commitDraft = (value) => {
26+
clearTimeout(commitTimerRef.current);
27+
if (value !== (pythonPath || '')) onPythonPathChange(value);
28+
};
29+
const handleDraftChange = (value) => {
30+
setDraftPath(value);
31+
clearTimeout(commitTimerRef.current);
32+
commitTimerRef.current = setTimeout(() => commitDraft(value), 800);
33+
};
1534

1635
// Closing the install EventSource on unmount stops setInstalling /
1736
// setInstallLog calls firing on a torn-down component if the user
@@ -143,8 +162,9 @@ export default function LocalSetupPanel({ pythonPath, onPythonPathChange, onPack
143162
<div className="flex items-center gap-2">
144163
<input
145164
type="text"
146-
value={pythonPath || ''}
147-
onChange={(e) => onPythonPathChange(e.target.value)}
165+
value={draftPath}
166+
onChange={(e) => handleDraftChange(e.target.value)}
167+
onBlur={() => commitDraft(draftPath)}
148168
className="flex-1 bg-port-bg border border-port-border rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-port-accent"
149169
placeholder="/usr/local/bin/python3"
150170
/>

server/routes/imageGen.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,13 @@ router.get('/setup/check', asyncHandler(async (req, res) => {
685685
return res.status(400).json({ error: 'pythonPath must be a python interpreter (basename python/python3/python3.NN)' });
686686
}
687687
const health = await probePythonHealth(pythonPath);
688-
const archMismatch = !!(health.interpreterArch && health.interpreterArch !== HOST_ARCH);
688+
// The arch warning is specifically about mlx wheels (arm64-only) on Apple
689+
// Silicon. A generic interpreterArch !== HOST_ARCH compare would false-
690+
// positive on Windows (Python reports `AMD64`, Node reports `x86_64`) and
691+
// on hypothetical arm64 Linux — where mlx isn't even in REQUIRED_PACKAGES.
692+
const archMismatch = process.platform === 'darwin'
693+
&& HOST_ARCH === 'arm64'
694+
&& health.interpreterArch === 'x86_64';
689695
const suggestedArm64Python = archMismatch ? await detectArm64Python() : null;
690696
res.json({
691697
pythonPath,

0 commit comments

Comments
 (0)