fix:Keep Jira linked work items attached when the composer project changes (#7770)

* Keep Jira linked work items attached when the composer project changes

Repo/project switches in the new-workspace composer cleared every linked
work item except Linear, so starting a workspace from a Jira task and then
picking the actual implementation project silently dropped the ticket link.
Route all three switch paths through a shared isRepoScopedLinkedWorkItem
predicate: GitHub/GitLab sources stay repo-scoped and clear on a switch,
Linear/Jira issues stay attached.

* test(new-workspace): drop dead isLinearLinkedWorkItem, harden preserve-predicate coverage

Follow-up to the Jira-preservation fix (review findings):
- Remove isLinearLinkedWorkItem: no production consumer remains after all three
  composer switch paths route through shouldPreserveWorkspaceSourceOnRepoChange.
- Pin the clear cases in workspace-source.test.ts (GitLab explicit + inferred,
  null) that both delegating paths depend on, not just GitHub.

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
hoonsbory
2026-07-20 15:05:23 -07:00
committed by GitHub
co-authored by Orca Jinjing
parent e109e78ebf
commit e218dfbf8b
4 changed files with 219 additions and 10 deletions
@@ -34,6 +34,26 @@ describe('workspace source policy', () => {
it('preserves global work-item sources across repo changes', () => {
expect(shouldPreserveWorkspaceSourceOnRepoChange(linear)).toBe(true)
expect(
shouldPreserveWorkspaceSourceOnRepoChange({
provider: 'jira',
type: 'issue',
number: 0,
title: 'Workspace scoped',
url: 'https://acme.atlassian.net/browse/FUS-1'
})
).toBe(true)
// Why: Jira items picked from smart search may arrive without an explicit
// provider; preservation must still hold via URL/identifier inference.
expect(
shouldPreserveWorkspaceSourceOnRepoChange({
type: 'issue',
number: 0,
title: 'Inferred Jira',
url: 'https://acme.atlassian.net/browse/FUS-1',
jiraIdentifier: 'FUS-1'
})
).toBe(true)
expect(
shouldPreserveWorkspaceSourceOnRepoChange({
provider: 'github',
@@ -43,6 +63,27 @@ describe('workspace source policy', () => {
url: 'https://github.com/o/r/issues/1'
})
).toBe(false)
// Why: GitLab is repo-scoped; pin both the explicit MR and the
// URL-inferred shape clear, since folder-source/project-group paths delegate here.
expect(
shouldPreserveWorkspaceSourceOnRepoChange({
provider: 'gitlab',
type: 'mr',
number: 2,
title: 'Repo scoped MR',
url: 'https://gitlab.com/o/r/-/merge_requests/2'
})
).toBe(false)
expect(
shouldPreserveWorkspaceSourceOnRepoChange({
type: 'issue',
number: 3,
title: 'Inferred GitLab',
url: 'https://gitlab.example.com/g/p/-/work_items/3'
})
).toBe(false)
// Why: a null source (branch-only) has nothing to preserve; callers guard on this.
expect(shouldPreserveWorkspaceSourceOnRepoChange(null)).toBe(false)
})
it('shares provider inference, selection labels, and auto-name gates', () => {