Skip to content

fix(dashboard): prevent stale saving indicator when desc requests overlap - #38294

Closed
AhmetArif0 wants to merge 1 commit into
NousResearch:mainfrom
AhmetArif0:fix/desktop-profiles-desc-saving-indicator
Closed

fix(dashboard): prevent stale saving indicator when desc requests overlap#38294
AhmetArif0 wants to merge 1 commit into
NousResearch:mainfrom
AhmetArif0:fix/desktop-profiles-desc-saving-indicator

Conversation

@AhmetArif0

Copy link
Copy Markdown
Contributor

Problem

handleSaveDesc and handleAutoDescribe on the Profiles page both set descSaving / describing to true at the start of a request, then unconditionally cleared them in finally:

} finally {
  setDescSaving(false);   // always runs
}

All other side-effects in these handlers are already guarded by if (activeDescRequest.current === name) to ignore stale responses — but the loading flag was not.

Reproduction:

  1. Open Profile A's description editor and click Save (request in-flight).
  2. Quickly open Profile B's description editor and click Save.
  3. Profile A's request resolves → finally fires → setDescSaving(false) clears the indicator even though Profile B's request is still in-flight.
  4. The "Saving…" button reverts to "Save" while the write hasn't completed.

The same race exists in handleAutoDescribe with setDescribing.

Fix

Add descSavingCount and describingCount refs that count concurrent in-flight requests. The loading flag is cleared only when the counter reaches zero — i.e. all overlapping requests have settled:

const descSavingCount = useRef(0);

const handleSaveDesc = async (name: string) => {
  descSavingCount.current += 1;
  setDescSaving(true);
  ...
  } finally {
    descSavingCount.current -= 1;
    if (descSavingCount.current === 0) setDescSaving(false);
  }
};

This mirrors the existing activeDescRequest guard pattern already used throughout these handlers.

Test plan

  • Open Profile A description editor, click Save, then immediately open Profile B description editor and click Save → "Saving…" stays visible until both writes complete
  • Single save (normal case) → loading indicator clears after the single request settles
  • Auto-generate description while a manual save is in-flight → describing indicator is not cleared early

handleSaveDesc and handleAutoDescribe both set their loading flag in a
try block but always cleared it unconditionally in finally. When a user
opened profile A's description editor, clicked Save, then quickly
switched to profile B's editor and saved, profile A's resolving request
would clear descSaving/describing while profile B's request was still
in-flight, making the "Saving…" indicator disappear prematurely.

Track concurrent in-flight counts with descSavingCount and
describingCount refs (mirrors the existing activeDescRequest guard
pattern). The loading flag is cleared only when the counter reaches
zero, i.e. all overlapping requests have settled.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have labels Jun 3, 2026
@teknium1

teknium1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Merged via PR #39070. Your commit was cherry-picked onto current main as de370fd with your authorship preserved in git log. Thanks!

@teknium1 teknium1 closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants