Skip to content

Mouse Without Borders: deduplicate machine entries in device layout#46863

Open
DaveT1991 wants to merge 3 commits intomicrosoft:mainfrom
DaveT1991:fix/mwb-duplicate-machine-in-device-layout
Open

Mouse Without Borders: deduplicate machine entries in device layout#46863
DaveT1991 wants to merge 3 commits intomicrosoft:mainfrom
DaveT1991:fix/mwb-duplicate-machine-in-device-layout

Conversation

@DaveT1991
Copy link
Copy Markdown

Summary

Two scenarios caused a duplicate machine to appear in the Device Layout
that the user had no way to remove:

  1. MachinePool with multiple IDs for the same name — if a machine
    reconnected and was assigned a new ID, MachinePool could hold
    "PC1:ID1,PC1:ID2". The available-machine list was built without
    deduplication, opening the door for both entries to fill slots.

  2. Persisted duplicate in the saved matrix — the removal loop only
    checked whether each slot's name was still in MachinePool. It never
    checked for duplicates within the matrix itself, so a duplicate
    saved in an earlier session survived every reload with no way to clear it.

Changes (MouseWithoutBordersViewModel.csLoadMachineMatrixString):

  • Build availableMachines through a HashSet so each name appears at
    most once (case-insensitive, matching MachinePool.NamesAreEqual).
  • Track seen names in a second HashSet while iterating the saved matrix;
    any slot whose name was already seen is cleared to string.Empty and
    editedTheMatrix is set so the fix is persisted immediately.
  • Made all Contains calls case-insensitive for consistency.

Issues Fixed

Fixes #46858

DaveT1991 and others added 3 commits April 9, 2026 17:37
The schwa (ə) is an IPA phonetic symbol, not an Italian accented letter,
and is already covered by the IPA language set. The Euro sign (€) is a
currency symbol and does not belong in a language-specific accent set.

Italian only uses è and é as accented forms of the letter e.

Fixes microsoft#46857
When loading the machine matrix, two scenarios could produce a duplicate
machine slot that the user had no way to remove:

1. MachinePool stored the same machine name under multiple IDs (e.g. after
   a reconnect with a new ID). The available-machine list was built without
   deduplication, so both entries could end up racing for the same slot.

2. A matrix persisted from an earlier session already contained a duplicate
   name. The removal loop only checked availability against MachinePool, so
   the duplicate passed through and was preserved on every reload.

Fix both by:
- Deduplicating the available-machine list as it is built from MachinePool
  (case-insensitive, matching the rest of the codebase).
- Tracking seen names in a HashSet while iterating the saved matrix and
  clearing any slot whose name has already appeared earlier.
- Making all Contains comparisons case-insensitive for consistency.

Fixes microsoft#46858
@daverayment
Copy link
Copy Markdown
Collaborator

This does not follow the PR template, includes 2 commits unrelated to the issue, and appears AI generated.

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.

Cannot Delete Duplicate Machine in Device Layout in Mouse without Borders

2 participants