Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
perf(jira): resolve the project-sort collator once per sort (STA-12861) (#36107)
Jinwoo Honga3ddc754143a
diff --git a/src/renderer/src/components/task-page/jira/task-page-jira-project-selection.test.ts b/src/renderer/src/components/task-page/jira/task-page-jira-project-selection.test.tsindex a05075ea236..f660a6d791e 100644--- a/src/renderer/src/components/task-page/jira/task-page-jira-project-selection.test.ts+++ b/src/renderer/src/components/task-page/jira/task-page-jira-project-selection.test.ts@@ -1,8 +1,8 @@import { describe, expect, it } from 'vitest'import {- compareJiraProjectsByDisplayLabel,- getJiraProjectSelectionKey+ getJiraProjectSelectionKey,+ jiraProjectDisplayLabelComparator} from './task-page-jira-project-selection'import type { JiraProject } from '../../../../../shared/jira/jira-types'@@ -24,10 +24,10 @@ describe('getJiraProjectSelectionKey', () => {})})-describe('compareJiraProjectsByDisplayLabel', () => {+describe('jiraProjectDisplayLabelComparator', () => {const sortOf = (projects: JiraProject[], includeSiteName: boolean): string[] =>[...projects]- .sort((a, b) => compareJiraProjectsByDisplayLabel(a, b, includeSiteName))+ .sort(jiraProjectDisplayLabelComparator(includeSiteName)).map((entry) => `${entry.siteName ?? ''}/${entry.name}/${entry.key}`)it('orders by site name first when site names are included', () => {@@ -61,7 +61,7 @@ describe('compareJiraProjectsByDisplayLabel', () => {})it('returns 0 for projects with identical display labels', () => {- expect(compareJiraProjectsByDisplayLabel(project(), project({ id: '2' }), true)).toBe(0)+ expect(jiraProjectDisplayLabelComparator(true)(project(), project({ id: '2' }))).toBe(0)})it('treats a missing site name as an empty string when comparing sites', () => {diff --git a/src/renderer/src/components/task-page/jira/task-page-jira-project-selection.ts b/src/renderer/src/components/task-page/jira/task-page-jira-project-selection.tsindex 61f537e2c5e..83ee83ef866 100644--- a/src/renderer/src/components/task-page/jira/task-page-jira-project-selection.ts+++ b/src/renderer/src/components/task-page/jira/task-page-jira-project-selection.ts@@ -10,20 +10,22 @@ const JIRA_PROJECT_LABEL_OPTIONS: Intl.CollatorOptions = {sensitivity: 'base'}-export function compareJiraProjectsByDisplayLabel(- a: JiraProject,- b: JiraProject,+// Why: resolve the UI-language collator once per sort, not on every comparison.+export function jiraProjectDisplayLabelComparator(includeSiteName: boolean-): number {- const siteComparison = includeSiteName- ? uiCollator(JIRA_PROJECT_LABEL_OPTIONS).compare(a.siteName ?? '', b.siteName ?? '')- : 0- if (siteComparison !== 0) {- return siteComparison+): (a: JiraProject, b: JiraProject) => number {+ const collator = uiCollator(JIRA_PROJECT_LABEL_OPTIONS)+ return (a, b) => {+ const siteComparison = includeSiteName+ ? collator.compare(a.siteName ?? '', b.siteName ?? '')+ : 0+ if (siteComparison !== 0) {+ return siteComparison+ }+ const nameComparison = collator.compare(a.name, b.name)+ if (nameComparison !== 0) {+ return nameComparison+ }+ return collator.compare(a.key, b.key)}- const nameComparison = uiCollator(JIRA_PROJECT_LABEL_OPTIONS).compare(a.name, b.name)- if (nameComparison !== 0) {- return nameComparison- }- return uiCollator(JIRA_PROJECT_LABEL_OPTIONS).compare(a.key, b.key)}diff --git a/src/renderer/src/components/task-page/jira/use-task-page-jira-creation-projects.ts b/src/renderer/src/components/task-page/jira/use-task-page-jira-creation-projects.tsindex 2d61ba39987..aa45f87592d 100644--- a/src/renderer/src/components/task-page/jira/use-task-page-jira-creation-projects.ts+++ b/src/renderer/src/components/task-page/jira/use-task-page-jira-creation-projects.ts@@ -5,7 +5,7 @@ import { useUiLanguageRevision } from '@/i18n/use-ui-language-revision'import { filterJiraProjectPickerProjects } from '@/components/jira-project-picker-filter'import { isVisibleJiraCreateField } from '@/components/task-page/jira/task-page-jira-create-fields'import {- compareJiraProjectsByDisplayLabel,+ jiraProjectDisplayLabelComparator,getJiraProjectSelectionKey} from '@/components/task-page/jira/task-page-jira-project-selection'@@ -33,8 +33,8 @@ export function useTaskPageJiraCreationProjects(model: TaskPageJiraCreationStateconst languageRevision = useUiLanguageRevision()const sortedAvailableJiraProjects = useMemo(() =>- [...availableJiraProjects].sort((a, b) =>- compareJiraProjectsByDisplayLabel(a, b, includeJiraSiteNameInProjectLabel)+ [...availableJiraProjects].sort(+ jiraProjectDisplayLabelComparator(includeJiraSiteNameInProjectLabel)),// oxlint-disable-next-line react-hooks/exhaustive-deps -- the comparator collates in the UI language.[availableJiraProjects, includeJiraSiteNameInProjectLabel, languageRevision]