Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (claude): stop EventSource reconnect double-install and guard concurrent HF installs
[._.]/ Adam Eivy28c995b58177
diff --git a/client/src/pages/Loras.jsx b/client/src/pages/Loras.jsxindex 07e22d1e5a..b2cdf699af 100644--- a/client/src/pages/Loras.jsx+++ b/client/src/pages/Loras.jsx@@ -166,7 +166,10 @@ export default function Loras() {// Shared install runner: `family` is undefined for the first attempt// (server autodetects) and set to the override on the inline-confirm retry.const runHfInstall = useCallback(async (url, family) => {- if (!url || hfInstalling) return;+ // Cross-guard against the curated video quick-install: both write the shared+ // hfProgress, so allowing them to overlap makes both progress readouts show+ // interleaved byte counts. Only one HF install runs at a time.+ if (!url || hfInstalling || installingVideoRepo) return;setHfInstalling(true);setHfProgress(null);await installLoraFromHuggingfaceStream({ url, family, onProgress: setHfProgress })@@ -187,7 +190,7 @@ export default function Loras() {}}).finally(() => { setHfInstalling(false); setHfProgress(null); });- }, [hfInstalling, refresh]);+ }, [hfInstalling, installingVideoRepo, refresh]);const handleHfInstall = useCallback((e) => {e?.preventDefault?.();@@ -200,7 +203,9 @@ export default function Loras() {// in-flight repo in its own state because the Civitai `installingSuggestion`// key is modelId/versionId-based — video installs have neither.const installVideoSuggestion = useCallback(async (card) => {- if (!card?.installUrl || installingVideoRepo) return;+ // Cross-guard against the form install (see runHfInstall) — one HF install+ // at a time so they don't clobber the shared hfProgress.+ if (!card?.installUrl || installingVideoRepo || hfInstalling) return;setInstallingVideoRepo(card.repo);setHfProgress(null);await installLoraFromHuggingfaceStream({ url: card.installUrl, family: card.runnerFamily, onProgress: setHfProgress })@@ -210,7 +215,7 @@ export default function Loras() {}).catch((err) => toast.error(err?.message || 'HuggingFace install failed')).finally(() => { setInstallingVideoRepo(null); setHfProgress(null); });- }, [installingVideoRepo, refresh]);+ }, [installingVideoRepo, hfInstalling, refresh]);const handleDelete = async (filename) => {setDeleting(filename);@@ -300,7 +305,7 @@ export default function Loras() {/><buttontype="submit"- disabled={hfInstalling || !hfUrl.trim()}+ disabled={hfInstalling || !!installingVideoRepo || !hfUrl.trim()}className="bg-port-accent text-white px-4 py-2 rounded text-sm font-medium hover:bg-port-accent/90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2">{hfInstalling ? (hfPct != null ? `Downloading ${hfPct}%` : 'Downloading…') : 'Install'}@@ -369,6 +374,7 @@ export default function Loras() {installingSuggestionKey={installingSuggestion}installingVideoRepo={installingVideoRepo}installingVideoProgress={hfProgress}+ videoInstallBusy={hfInstalling}onRefresh={() => refreshSuggestions({ force: true })}onInstallVideo={installVideoSuggestion}onInstall={async (card, url, versionId) => {@@ -466,7 +472,7 @@ function MediaFilter({ value, onChange }) {);}-function SuggestionsPanel({ suggestions, loading, mediaFilter = 'all', installedFilenames, installedHfRepos, installingSuggestionKey, installingVideoRepo, installingVideoProgress, onRefresh, onInstall, onInstallVideo }) {+function SuggestionsPanel({ suggestions, loading, mediaFilter = 'all', installedFilenames, installedHfRepos, installingSuggestionKey, installingVideoRepo, installingVideoProgress, videoInstallBusy, onRefresh, onInstall, onInstallVideo }) {const curated = suggestions?.curated || [];const runners = suggestions?.runners || {};const video = suggestions?.video || [];@@ -529,6 +535,7 @@ function SuggestionsPanel({ suggestions, loading, mediaFilter = 'all', installedinstalledHfRepos={installedHfRepos}installingVideoRepo={installingVideoRepo}installingVideoProgress={installingVideoProgress}+ videoInstallBusy={videoInstallBusy}onInstall={onInstallVideo}/>)}@@ -540,7 +547,7 @@ function SuggestionsPanel({ suggestions, loading, mediaFilter = 'all', installed// like the Civitai sections — it's a small hand-picked list installed via the// HF path. Installed-state matches on the repo (HF installs carry no// modelId/versionId).-function VideoSuggestionsSection({ cards, installedHfRepos, installingVideoRepo, installingVideoProgress, onInstall }) {+function VideoSuggestionsSection({ cards, installedHfRepos, installingVideoRepo, installingVideoProgress, videoInstallBusy, onInstall }) {const list = cards || [];return (<div>@@ -563,6 +570,9 @@ function VideoSuggestionsSection({ cards, installedHfRepos, installingVideoRepo,installed={installedHfRepos?.has(card.repo)}installing={installingVideoRepo === card.repo}progress={installingVideoRepo === card.repo ? installingVideoProgress : null}+ // Disable every quick-install button while ANY HF install is in+ // flight (this card's, another card's, or the form's) — one at a time.+ busy={!!installingVideoRepo || videoInstallBusy}onInstall={onInstall}/>))}@@ -572,7 +582,7 @@ function VideoSuggestionsSection({ cards, installedHfRepos, installingVideoRepo,);}-function VideoSuggestionCard({ card, installed, installing, progress, onInstall }) {+function VideoSuggestionCard({ card, installed, installing, progress, busy, onInstall }) {const pct = pctOf(progress);return (<div className="bg-port-card border border-port-border rounded-lg overflow-hidden flex flex-col">@@ -606,8 +616,8 @@ function VideoSuggestionCard({ card, installed, installing, progress, onInstall<buttontype="button"onClick={() => onInstall(card)}- disabled={installing}- className="flex-1 bg-port-accent text-white px-3 py-1.5 rounded text-xs font-medium hover:bg-port-accent/90 disabled:opacity-50"+ disabled={installing || busy}+ className="flex-1 bg-port-accent text-white px-3 py-1.5 rounded text-xs font-medium hover:bg-port-accent/90 disabled:opacity-50 disabled:cursor-not-allowed">{installing ? (pct != null ? `Installing ${pct}%` : 'Installing…') : 'Quick install'}</button>diff --git a/client/src/services/apiImageVideo.js b/client/src/services/apiImageVideo.jsindex 2aa987a060..1f2a50ab48 100644--- a/client/src/services/apiImageVideo.js+++ b/client/src/services/apiImageVideo.js@@ -306,13 +306,16 @@ export function installLoraFromHuggingfaceStream({ url, family, onProgress } = {}};es.onerror = () => {- // A normal completion/error already closed the ES above; this only fires- // on a real transport failure (non-2xx open, dropped stream), which- // EventSource surfaces as readyState CLOSED with no auto-retry. Reject so- // the caller's spinner clears instead of hanging forever.- if (es.readyState === EventSource.CLOSED) {- reject(new Error('Download stream closed before completing'));- }+ // This is a ONE-SHOT, non-idempotent install — a reconnect would start a+ // second server-side download of the same multi-GB LoRA. EventSource+ // auto-reconnects on ANY transport drop (firing onerror with readyState+ // CONNECTING, not CLOSED), so close it on the first error to stop the+ // reconnect, then reject. A normal completion/error already closed the ES+ // in onmessage, so this fires only on a genuine transport failure (a+ // failed open, or a drop before the terminal frame) — the settled promise+ // makes a late reject a no-op.+ es.close();+ reject(new Error('Download stream closed before completing'));};});}