Skip to content

fix(ui): remove-all routes skips locked routes (#1298)#1370

Open
iron-hope-shop wants to merge 2 commits intoAzgaar:masterfrom
iron-hope-shop:fix/remove-all-routes-respect-locks
Open

fix(ui): remove-all routes skips locked routes (#1298)#1370
iron-hope-shop wants to merge 2 commits intoAzgaar:masterfrom
iron-hope-shop:fix/remove-all-routes-respect-locks

Conversation

@iron-hope-shop
Copy link
Copy Markdown

Summary
"Remove all routes" in the Routes Overview now deletes only unlocked routes. Locked routes and their geometry stay. Users who want a full wipe can unlock everything first (existing lock/unlock-all control).

Motivation
Implements the behavior requested in #1298: bulk delete should ignore locked routes so you can clear generated routes without losing hand-pinned or important ones.

Changes

  • triggerAllRoutesRemove: filter !route.lock, call Routes.remove per unlocked route (keeps pack.cells.routes and SVG in sync).
  • If every route is locked: show a tip instead of opening the delete dialog.
  • If there are no routes: show a tip.
  • Confirmation copy clarifies counts when some routes stay locked.
  • Tooltip on the trash button: unlocked-only behavior.

How to test

  1. Lock one route → remove all → locked route remains.
  2. Unlock all → remove all → all removed.
  3. Lock all → remove all → tip, nothing deleted.

#1298

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 5, 2026

Deploy Preview for afmg ready!

Name Link
🔨 Latest commit 66e8d05
🔍 Latest deploy log https://app.netlify.com/projects/afmg/deploys/69d9509485577200084a7cfa
😎 Deploy Preview https://deploy-preview-1370--afmg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Azgaar
Copy link
Copy Markdown
Owner

Azgaar commented Apr 5, 2026

Looks good, thanks for the contribution!

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

Updates the Routes Overview “Remove all” action to respect route locks, enabling users to clear generated/unwanted routes without deleting hand-pinned (locked) ones, aligning bulk-delete behavior with issue #1298.

Changes:

  • Bulk delete now targets only unlocked routes and uses Routes.remove per route to keep data + SVG in sync.
  • Adds user feedback when there are no routes or when all routes are locked (tip instead of confirmation).
  • Updates confirmation wording and the trash button tooltip to clarify locked routes are retained.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/index.html Updates the Routes Overview trash button tooltip to clarify it removes only unlocked routes.
public/modules/ui/routes-overview.js Implements unlocked-only bulk deletion, adds empty/all-locked tips, and updates confirmation message/title accordingly.

pack.routes = [];
routes.selectAll("path").remove();

for (const route of [...toRemove]) {
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

toRemove is computed when opening the dialog and then captured in the Remove callback. Because #alert dialogs are non-modal by default, a user can lock/unlock routes while the confirmation is open; currently a route that becomes locked after opening can still be deleted. Consider recomputing the list of unlocked routes inside the Remove handler (or making the dialog modal) so the action always respects the current lock state.

Suggested change
for (const route of [...toRemove]) {
const routesToRemove = pack.routes.filter(route => !route.lock);
if (!routesToRemove.length) {
if (!pack.routes.length) {
tip("There are no routes to remove", false, "error");
} else {
tip("All routes are locked. Unlock routes to remove them, or use Lock all to unlock first.", false, "error");
}
$(this).dialog("close");
return;
}
for (const route of [...routesToRemove]) {

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

that should be fine, Copilot. A very rare case.

Comment on lines 194 to 199
Remove: function () {
pack.cells.routes = {};
pack.routes = [];
routes.selectAll("path").remove();

for (const route of [...toRemove]) {
Routes.remove(route);
}
routesOverviewAddLines();
$(this).dialog("close");
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

After removing routes via Routes.remove, pack.cells.routes will keep many empty per-cell objects (since Routes.remove deletes only entries, not empty nodes). If all routes are removed, this leaves a large sparse object that bloats saves/exports (save.js JSON.stringify) and adds overhead to Routes.isConnected checks. Consider cleaning up empty pack.cells.routes[from] objects after the loop (or rebuilding links with Routes.buildLinks(pack.routes) / resetting to {} when pack.routes.length === 0).

Copilot uses AI. Check for mistakes.
@Azgaar
Copy link
Copy Markdown
Owner

Azgaar commented Apr 8, 2026

@iron-hope-shop, could you please address the comments? I will be able to merge then.

@iron-hope-shop
Copy link
Copy Markdown
Author

the remove action now recomputes unlocked routes at confirm time, and after bulk removal pack.cells.routes is rebuilt with Routes.buildLinks(pack.routes)

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