Skip to content

feat(start-menu): add context menu with pin/unpin for apps#64

Open
PrayagCodes wants to merge 1 commit into
codepath:mainfrom
PrayagCodes:feat/start-menu-context-menu
Open

feat(start-menu): add context menu with pin/unpin for apps#64
PrayagCodes wants to merge 1 commit into
codepath:mainfrom
PrayagCodes:feat/start-menu-context-menu

Conversation

@PrayagCodes

Copy link
Copy Markdown

Summary

Adds right-click context menu support for apps in the start menu, allowing users to launch apps and pin/unpin them to the taskbar directly from the start menu without needing to launch the app first.

Problem

Previously, users could only pin apps to the taskbar by:

  1. Launching the app first
  2. Then right-clicking the app's taskbar item to pin it

This created unnecessary friction for users who wanted to organize their taskbar without launching apps.

Solution

This PR adds a context menu to start menu apps that provides:

  • Open option to launch the app
  • Keep in Taskbar / Remove from Taskbar options based on current pin state
  • Full pin/unpin functionality that persists across sessions
  • Mobile support via long-press gesture

Changes

Frontend (src/gui/src/UI/UIDesktop.js)

  • ✅ Added context menu event handler for .start-app elements (right-click/taphold)
  • ✅ Implemented isAppPinned() helper function to check pinned state
  • ✅ Implemented pinAppToTaskbar() function to add apps to taskbar
  • ✅ Implemented unpinAppFromTaskbar() function to remove apps from taskbar
  • ✅ Fixed state synchronization in update_taskbar() to keep in-memory state in sync with DOM
  • ✅ Added UITaskbarItem import

Backend (src/backend/src/routers/update-taskbar-items.js)

  • ✅ Fixed database persistence by properly stringifying taskbar items array

Technical Details

  • Uses existing UIContextMenu component for consistency
  • Follows same pin/unpin patterns as taskbar item context menus
  • Closes existing context menus before opening new ones to prevent multiple menus
  • Synchronizes window.user.taskbar_items with DOM state
  • Handles edge cases (apps with open windows, already pinned apps, etc.)

Testing

Manual Testing Checklist

  • Right-click unpinned app shows "Open" and "Keep in Taskbar"
  • Right-click pinned app shows "Open" and "Remove from Taskbar"
  • Clicking "Keep in Taskbar" adds app to taskbar immediately
  • Clicking "Remove from Taskbar" removes app from taskbar (if no windows open)
  • Unpinning app with open windows keeps it in taskbar until windows close
  • Changes persist after page refresh
  • Only one context menu appears at a time
  • Context menu closes when clicking outside
  • Context menu closes when selecting "Open"
  • Long-press works on mobile devices

Test Scenarios

  1. Pin from start menu

    • Right-click unpinned app → Click "Keep in Taskbar"
    • ✅ App appears in taskbar immediately
    • ✅ Refresh page → App remains pinned
  2. Unpin from start menu (no windows)

    • Right-click pinned app → Click "Remove from Taskbar"
    • ✅ App disappears from taskbar immediately
    • ✅ Refresh page → App remains unpinned
  3. Unpin with windows open

    • Launch app → Right-click in start menu → Click "Remove from Taskbar"
    • ✅ App stays in taskbar (window is open)
    • ✅ Close window → App disappears from taskbar
  4. Multiple menus prevention

    • Right-click app A → Right-click app B
    • ✅ First menu closes, second menu opens
Add right-click context menu to start menu apps with 'Open' and
pin/unpin options. Users can now pin/unpin apps to taskbar directly
from start menu without launching them first.

- Add contextmenu handler for .start-app elements
- Implement pinAppToTaskbar() and unpinAppFromTaskbar() functions
- Fix window.user.taskbar_items state synchronization
- Fix backend persistence (JSON.stringify taskbar_items)
- Close existing menus before opening new ones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant