Sorting Applications in Account Console #50948 - #51245
Conversation
Signed-off-by: Himanshi Gupta <higupta@higupta-thinkpadt14gen5.rmtin.csb>
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds deterministic alphabetical sorting of Applications in the Account Console UI and verifies it via an end-to-end test.
Changes:
- Sort fetched applications by
clientName(fallbackclientId) before rendering. - Add a Playwright spec asserting the applications list is displayed in alphabetical order.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| js/apps/account-ui/src/applications/Applications.tsx | Sorts the applications array before storing it in component state. |
| js/apps/account-ui/test/applications.spec.ts | Adds a UI test that mocks the /applications response and verifies display order. |
| test("sorts applications alphabetically", async ({ page }) => { | ||
| await using testBed = await createTestBed(); | ||
|
|
||
| await page.route("**/applications", async (route) => { |
Signed-off-by: Himanshi Gupta <higupta@higupta-thinkpadt14gen5.rmtin.csb>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
js/apps/account-ui/src/applications/Applications.tsx:66
localeComparewill throw if(a.clientName || a.clientId)(or the RHS) isundefined(e.g., if an API response is missing both). To make this robust, coerce both sort keys to strings with a safe fallback (e.g.,a.clientName ?? a.clientId ?? "") before callinglocaleCompare.
(signal) => getApplications({ signal, context }),
(clients) =>
setApplications(
[...clients]
.sort((a, b) =>
(a.clientName || a.clientId).localeCompare(
b.clientName || b.clientId,
),
)
.map((c) => ({ ...c, open: false })),
),
[key],
);
js/apps/account-ui/src/applications/Applications.tsx:66
- The indentation on these newly added lines appears to include non-standard whitespace (e.g., non-breaking spaces). This can create noisy diffs and potentially trip formatting/lint tooling. Please retype/reformat this block using the repo’s standard indentation (and run the formatter, if applicable) so it uses regular spaces.
(signal) => getApplications({ signal, context }),
(clients) =>
setApplications(
[...clients]
.sort((a, b) =>
(a.clientName || a.clientId).localeCompare(
b.clientName || b.clientId,
),
)
.map((c) => ({ ...c, open: false })),
),
[key],
);
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
js/apps/account-ui/src/applications/Applications.tsx:66
- These lines appear to contain non-standard indentation characters (e.g., non‑breaking spaces). This can cause formatting/lint churn and inconsistent diffs across editors/CI. Re-indent with regular spaces and run the repo formatter (e.g., Prettier/ESLint autofix) to normalize whitespace.
(signal) => getApplications({ signal, context }),
(clients) =>
setApplications(
[...clients]
.sort((a, b) =>
(a.clientName || a.clientId).localeCompare(
b.clientName || b.clientId,
),
)
.map((c) => ({ ...c, open: false })),
),
[key],
);
js/apps/account-ui/test/applications.spec.ts:44
- The UI sort now falls back to
clientIdwhenclientNameis missing, but the test data only coversclientNamesorting. Add at least one application withoutclientName(or with an empty string) and assert it is sorted byclientIdto cover the fallback path.
test("sorts applications alphabetically", async ({ page }) => {
await using testBed = await createTestBed();
await page.route("**/applications", async (route) => {
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify([
{
clientId: "zebra-client",
clientName: "Zebra Application",
},
{
clientId: "alpha-client",
clientName: "Alpha Application",
},
{
clientId: "beta-client",
clientName: "Beta Application",
},
]),
});
});
js/apps/account-ui/src/applications/Applications.tsx:62
- Optional:
localeComparewithout explicit options can produce case-sensitive or locale-dependent ordering that may surprise users (e.g., mixed case, diacritics). If the intended behavior is a consistent, case-insensitive alphabetical sort, consider passing explicitlocaleCompareoptions (e.g.,{ sensitivity: \"base\" }) or using the app’s active locale.
.sort((a, b) =>
(a.clientName || a.clientId).localeCompare(
b.clientName || b.clientId,
),
)
Signed-off-by: Himanshi Gupta <higupta@higupta-thinkpadt14gen5.rmtin.csb>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
js/apps/account-ui/src/applications/Applications.tsx:64
- The comparator uses the raw
clientName, but the list renderslabel(t, ...). Bundle-valued names such as${client_account-console}are therefore sorted under$rather than their localized display text, so the visible list is not alphabetical; compare the resolved labels instead.
(a.clientName || a.clientId).localeCompare(
b.clientName || b.clientId,
locale,
js/apps/account-ui/src/applications/Applications.tsx:66
- When two clients have the same displayed name, this comparator returns
0and preserves their nondeterministic order from the server'sHashSet, which conflicts with the issue's predictable-order goal. Add a stable secondary comparison such asclientId.
This issue also appears on line 62 of the same file.
.sort((a, b) =>
(a.clientName || a.clientId).localeCompare(
b.clientName || b.clientId,
locale,
),
)
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
js/apps/account-ui/src/applications/Applications.tsx:60
- The sort key is not always the name shown to the user:
label()translates bundle-backed client names such as${client_account-console}, while this compares the raw placeholder. Those built-in clients will therefore sort under$instead of their localized visible name; compare thelabel(t, ...)results used by the list rendering.
(a.clientName || a.clientId).localeCompare(
b.clientName || b.clientId,
closes #50948