Skip to content

Fix premature pin on failed profile add#39

Merged
ghostleek merged 2 commits intofix/show-profilefrom
copilot/sub-pr-38
Mar 4, 2026
Merged

Fix premature pin on failed profile add#39
ghostleek merged 2 commits intofix/show-profilefrom
copilot/sub-pr-38

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

handleAddExistingApp was calling togglePinnedApp before awaiting the /api/profile/add-app response. On API failure, the app stayed pinned on the homepage despite never being added to the profile.

Change

Move togglePinnedApp to execute only after addAppToProfile returns true:

// Before
const alreadyPinned = preferences.pinnedApps?.includes(appId);
if (!alreadyPinned) togglePinnedApp(appId);          // ← runs unconditionally

const added = await addAppToProfile(appId);
if (!added) { addToast('Failed to add app to profile', 'error'); return false; }

// After
const added = await addAppToProfile(appId);
if (!added) { addToast('Failed to add app to profile', 'error'); return false; }

const alreadyPinned = preferences.pinnedApps?.includes(appId);
if (!alreadyPinned) togglePinnedApp(appId);          // ← runs only on success

Pin state is now only updated when the API call confirms the app was successfully added to the profile.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
string-v2 Ready Ready Preview, Comment Mar 3, 2026 3:24pm

Co-authored-by: ghostleek <44336310+ghostleek@users.noreply.github.com>
Copilot AI changed the title [WIP] Update profile management UI and fix Opal logo issue Fix premature pin on failed profile add Mar 3, 2026
@ghostleek ghostleek requested a review from Copilot March 3, 2026 15:24
@ghostleek ghostleek marked this pull request as ready for review March 3, 2026 15:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents the homepage pin state from being updated when adding an existing app to a personal profile fails, ensuring UI state reflects the actual server-side outcome.

Changes:

  • Reorders handleAddExistingApp so the profile add API call is awaited before pinning.
  • Keeps the existing “only pin if not already pinned” behavior, but now only after a successful add.
  • Preserves existing success/failure toast behavior and profile reload on success.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ghostleek ghostleek merged commit b36a594 into fix/show-profile Mar 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants