From 9b0a4c95e0283e57526ac41e7e3ec8989c7bdf30 Mon Sep 17 00:00:00 2001 From: Jordi Wippert Date: Wed, 18 Nov 2026 22:13:49 +0100 Subject: [PATCH 1/6] test(client-runtime): Linear issue links in the conversation resolve to a bound project A Linear link reads through the project bound to its team, or is lent a project bound to Linear when no project is bound to that team. Without tracker bindings the link stays an ordinary link. Co-Authored-By: Claude Opus 5.5 --- .../client-runtime/src/issueLinks.test.ts | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/client-runtime/src/issueLinks.test.ts b/packages/client-runtime/src/issueLinks.test.ts index eef7524db4f8b..15455092c3cae 100644 --- a/packages/client-runtime/src/issueLinks.test.ts +++ b/packages/client-runtime/src/issueLinks.test.ts @@ -1,4 +1,9 @@ -import { EnvironmentId, ProjectId, SourceControlProviderKind } from "@t3tools/contracts"; +import { + EnvironmentId, + IssueTrackerKind, + ProjectId, + SourceControlProviderKind, +} from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; import { resolveIssueLinkTarget } from "./issueLinks.ts"; @@ -65,9 +70,37 @@ describe("resolveIssueLinkTarget", () => { expect(custom?.ref).toMatchObject({ projectId: "custom", host: "code.acme.test", key: "7" }); }); + it("reads a Linear issue through the project bound to its team, else lends a bound project", () => { + const trackerBindings = { + p1: { tracker: IssueTrackerKind.make("linear"), scope: "OPS" }, + p2: { tracker: IssueTrackerKind.make("linear"), scope: "ENG" }, + } as never; + const own = resolveIssueLinkTarget({ + url: "https://linear.app/acme/issue/ENG-12/fix-the-thing", + projects, + trackerBindings, + }); + expect(own?.ref).toEqual({ + projectId: "p2", + tracker: "linear", + host: "linear.app", + scope: "ENG", + key: "ENG-12", + }); + + const lent = resolveIssueLinkTarget({ + url: "https://linear.app/acme/issue/WEB-3", + projects, + trackerBindings, + preferredProjectId: ProjectId.make("p2"), + }); + expect(lent?.ref).toMatchObject({ projectId: "p2", scope: "WEB", key: "WEB-3" }); + }); + it.each([ "https://github.com.evil.example/acme/web/issues/7", "https://github.com/acme/web/pull/7", + "https://linear.app/acme/issue/ENG-12", ])("leaves %s an ordinary link", (url) => { expect(resolveIssueLinkTarget({ url, projects })).toBeNull(); }); From cbbf69b2c988e2a1e725edbdbb463ac176701068 Mon Sep 17 00:00:00 2001 From: Jordi Wippert Date: Wed, 18 Nov 2026 22:14:10 +0100 Subject: [PATCH 2/6] fix(client-runtime): Linear issue links in the conversation open beside the thread The server resolves Linear issue URLs since the Linear tracker landed, but the client link resolver only knew git hosts, so a Linear link in a chat opened as a browser page. The Linear URL parser moves to a shared module the client can import, and the resolver reads Linear links through the environment's tracker bindings: the project bound to the link's team, else any project bound to Linear, read-only. Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/native/useOpenPullRequest.ts | 16 ++++++- apps/web/src/lib/openIssueLink.ts | 10 +++++ packages/client-runtime/package.json | 1 + packages/client-runtime/src/issueLinks.ts | 45 ++++++++++++++++++- packages/issue-tracker-linear/package.json | 4 ++ .../src/server/LinearApi.ts | 5 ++- .../src/server/LinearIssueTracker.ts | 11 ++--- .../src/shared/issueUrl.ts | 14 ++++++ pnpm-lock.yaml | 3 ++ 9 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 packages/issue-tracker-linear/src/shared/issueUrl.ts diff --git a/apps/mobile/src/native/useOpenPullRequest.ts b/apps/mobile/src/native/useOpenPullRequest.ts index d6da186b0f23a..ee707e2bafa93 100644 --- a/apps/mobile/src/native/useOpenPullRequest.ts +++ b/apps/mobile/src/native/useOpenPullRequest.ts @@ -5,11 +5,12 @@ import { pullRequestCandidateForIssueLink, } from "../lib/pullRequestNavigation"; import { isAtomCommandInterrupted } from "@t3tools/client-runtime/state/runtime"; -import { EnvironmentId, ThreadId } from "@t3tools/contracts"; +import { EnvironmentId, type IssueTrackerConnectionList, ThreadId } from "@t3tools/contracts"; import { useProjects, useThreadShell } from "../state/entities"; import { tryOpenExternalUrl } from "../lib/openExternalUrl"; import { appAtomRegistry } from "../state/atom-registry"; import { environmentServerConfigsAtom } from "../state/server"; +import { issueTrackerEnvironment } from "../state/issueTrackers"; import { composerPullRequests } from "../state/pull-requests"; import { useAtomQueryRunner } from "../state/use-atom-query-runner"; import { withKnownPullRequestSummary } from "../state/use-thread-pr"; @@ -28,6 +29,10 @@ export function useNavigateToPullRequest(options?: { readonly replace?: boolean reportFailure: false, reportDefect: false, }); + const readTrackers = useAtomQueryRunner(issueTrackerEnvironment.connections, { + reportFailure: false, + reportDefect: false, + }); return async (url: string, context: PullRequestContext | null) => { // Read at press time so a config push does not hand every link a new handler. const serverConfigs = appAtomRegistry.get(environmentServerConfigsAtom); @@ -37,14 +42,21 @@ export function useNavigateToPullRequest(options?: { readonly replace?: boolean if (!destination) { // An issue link from the same text opens the issue; anything else leaves for the browser. const environmentId = context && EnvironmentId.make(context.environmentId); - const issue = + const resolveIssue = (trackerBindings?: IssueTrackerConnectionList["bindings"]) => environmentId && serverConfigs.get(environmentId)?.environment.capabilities.issues === true ? resolveIssueLinkTarget({ url, projects: projects.filter((project) => project.environmentId === environmentId), preferredProjectId: context.projectId, + trackerBindings, }) : null; + let issue = resolveIssue(); + if (!issue && environmentId) { + // Linear links resolve through the projects bound to a team in Settings. + const trackers = await readTrackers({ environmentId, input: {} }); + if (trackers._tag === "Success") issue = resolveIssue(trackers.value.bindings); + } if (!issue || !environmentId) return tryOpenExternalUrl(url, "pull-request"); const candidate = pullRequestCandidateForIssueLink(url, issue.ref); if (candidate) { diff --git a/apps/web/src/lib/openIssueLink.ts b/apps/web/src/lib/openIssueLink.ts index 96d545827bbb9..ab8a9df53fd83 100644 --- a/apps/web/src/lib/openIssueLink.ts +++ b/apps/web/src/lib/openIssueLink.ts @@ -6,6 +6,8 @@ import type { MouseEvent } from "react"; import { readIssueListPreferences } from "../components/issue/issueListPreferences"; import { ISSUES_PANEL_REF, PULL_REQUESTS_PANEL_REF, useRightPanelStore } from "../rightPanelStore"; import { useProjects, useServerConfigs } from "../state/entities"; +import { issueTrackerEnvironment } from "../state/issueTrackers"; +import { useEnvironmentQuery } from "../state/query"; /** * Opens an issue link beside the thread, and says whether it did. Anything else — a host no @@ -27,6 +29,13 @@ export function useOpenIssueLink( const allProjects = useProjects(); const serverConfigs = useServerConfigs(); const navigate = useNavigate(); + const threadEnvironmentId = threadRef?.environmentId; + const trackers = useEnvironmentQuery( + threadEnvironmentId !== undefined && + serverConfigs.get(threadEnvironmentId)?.environment.capabilities.issues === true + ? issueTrackerEnvironment.connections({ environmentId: threadEnvironmentId, input: {} }) + : null, + ); return (event, targetUrl, targetEnvironmentId) => { if (event.metaKey || event.ctrlKey) return false; const resolvedPanelRef = panelRef ?? threadRef; @@ -37,6 +46,7 @@ export function useOpenIssueLink( const target = resolveIssueLinkTarget({ url: targetUrl, projects: allProjects.filter((project) => project.environmentId === environmentId), + trackerBindings: environmentId === threadEnvironmentId ? trackers.data?.bindings : undefined, }); if (target === null) return false; event.preventDefault(); diff --git a/packages/client-runtime/package.json b/packages/client-runtime/package.json index 736abada9a390..1e0bac0f5ee02 100644 --- a/packages/client-runtime/package.json +++ b/packages/client-runtime/package.json @@ -627,6 +627,7 @@ "dependencies": { "@pierre/diffs": "catalog:", "@t3tools/contracts": "workspace:*", + "@t3tools/issue-tracker-linear": "workspace:*", "@t3tools/provider-acp-registry": "workspace:*", "@t3tools/provider-core": "workspace:*", "@t3tools/provider-cursor": "workspace:*", diff --git a/packages/client-runtime/src/issueLinks.ts b/packages/client-runtime/src/issueLinks.ts index 3509bbbf33ed5..4b499e6c1d83f 100644 --- a/packages/client-runtime/src/issueLinks.ts +++ b/packages/client-runtime/src/issueLinks.ts @@ -1,4 +1,8 @@ -import type { IssueRef } from "@t3tools/contracts"; +import type { IssueRef, IssueTrackerConnectionList } from "@t3tools/contracts"; +import { + LINEAR_TRACKER, + parseLinearIssueUrl, +} from "@t3tools/issue-tracker-linear/shared/issue-url"; import { sourceControlClients } from "./sourceControlClients.ts"; import type { EnvironmentProject } from "./state/shell.ts"; @@ -59,11 +63,13 @@ export function resolveIssueLinkTarget(input: { /** The projects of the environment the link is read in. */ readonly projects: ReadonlyArray; readonly preferredProjectId?: string | undefined; + /** The environment's standalone tracker bindings; without them a Linear link stays plain. */ + readonly trackerBindings?: IssueTrackerConnectionList["bindings"] | undefined; }): { readonly project: Project; readonly ref: IssueRef } | null { // A link names its server's port; a binding does only when its remote or web URL did. const authority = linkAuthority(input.url); const parsed = parseIssueLink(input.url, authority, input.projects); - if (parsed === null) return null; + if (parsed === null) return resolveLinearIssueLink(input); const { definition, link } = parsed; const onHost = input.projects.flatMap((project) => { const binding = projectIssueBinding(project); @@ -92,3 +98,38 @@ export function resolveIssueLinkTarget(input: { }, }; } + +/** A Linear link, read through the project bound to its team, else any project bound to Linear. */ +function resolveLinearIssueLink(input: { + readonly url: string; + readonly projects: ReadonlyArray; + readonly preferredProjectId?: string | undefined; + readonly trackerBindings?: IssueTrackerConnectionList["bindings"] | undefined; +}): { readonly project: Project; readonly ref: IssueRef } | null { + const bindings = input.trackerBindings; + if (bindings === undefined || !URL.canParse(input.url)) return null; + const link = parseLinearIssueUrl(new URL(input.url)); + if (link === null) return null; + const bound = input.projects.flatMap((project) => { + const binding = bindings[project.id]; + return binding?.tracker === LINEAR_TRACKER ? [{ project, scope: binding.scope }] : []; + }); + const preferFirst = (candidates: typeof bound) => + candidates.find((candidate) => candidate.project.id === input.preferredProjectId) ?? + candidates[0]; + const own = preferFirst( + bound.filter((candidate) => candidate.scope.toLowerCase() === link.scope.toLowerCase()), + ); + const lender = own ?? preferFirst(bound); + if (lender === undefined) return null; + return { + project: lender.project, + ref: { + projectId: lender.project.id, + tracker: LINEAR_TRACKER, + host: link.host, + scope: own === undefined ? link.scope : lender.scope, + key: link.key, + }, + }; +} diff --git a/packages/issue-tracker-linear/package.json b/packages/issue-tracker-linear/package.json index b5d4d41b5222b..519fdc15dc74f 100644 --- a/packages/issue-tracker-linear/package.json +++ b/packages/issue-tracker-linear/package.json @@ -3,6 +3,10 @@ "private": true, "type": "module", "exports": { + "./shared/issue-url": { + "types": "./src/shared/issueUrl.ts", + "import": "./src/shared/issueUrl.ts" + }, "./server/driver": { "types": "./src/server/driver.ts", "import": "./src/server/driver.ts" diff --git a/packages/issue-tracker-linear/src/server/LinearApi.ts b/packages/issue-tracker-linear/src/server/LinearApi.ts index a89e0988b70c8..156430a668d00 100644 --- a/packages/issue-tracker-linear/src/server/LinearApi.ts +++ b/packages/issue-tracker-linear/src/server/LinearApi.ts @@ -18,10 +18,11 @@ import { } from "effect/graphql"; import { HttpClient } from "effect/http"; import * as Headers from "effect/http/Headers"; -import { IssueTrackerKind } from "@t3tools/contracts"; import { IssueTrackerError } from "@t3tools/source-control-core/server/IssueTracker"; import * as IssueTrackerHost from "@t3tools/source-control-core/server/IssueTrackerHost"; +import { LINEAR_TRACKER } from "../shared/issueUrl.ts"; + import type { CommentCreateInput, IssueCreateInput, @@ -53,7 +54,7 @@ export type { LinearWorkflowState } from "./LinearApi.graphql.ts"; export type LinearAttachment = Attachment; export type LinearHistoryEntry = IssueHistory; -export const KIND = IssueTrackerKind.make("linear"); +export const KIND = LINEAR_TRACKER; const DEFAULT_API_URL = "https://api.linear.app/graphql"; const LinearApiConfig = Config.all({ diff --git a/packages/issue-tracker-linear/src/server/LinearIssueTracker.ts b/packages/issue-tracker-linear/src/server/LinearIssueTracker.ts index 885b016b23ebf..10cad7da67d12 100644 --- a/packages/issue-tracker-linear/src/server/LinearIssueTracker.ts +++ b/packages/issue-tracker-linear/src/server/LinearIssueTracker.ts @@ -26,12 +26,13 @@ import { type TrackerIssueSummary, } from "@t3tools/source-control-core/server/IssueTracker"; +import { LINEAR_HOST, parseLinearIssueUrl } from "../shared/issueUrl.ts"; import * as LinearApi from "./LinearApi.ts"; const DESCRIPTOR: StandaloneIssueTrackerDescriptor = { tracker: LinearApi.KIND, displayName: "Linear", - host: "linear.app", + host: LINEAR_HOST, scopeNoun: "team", credential: { label: "Personal API key", @@ -415,13 +416,7 @@ export const make: Effect.Effect { - if (url.protocol !== "https:" || url.host.toLowerCase() !== DESCRIPTOR.host) return null; - const [, workspace, resource, key] = url.pathname.split("/"); - if (!workspace || resource !== "issue" || key === undefined) return null; - const scope = /^([A-Z][A-Z0-9_]*)-[1-9][0-9]*$/.exec(key)?.[1]; - return scope === undefined ? null : { host: DESCRIPTOR.host, workspace, scope, key }; - }, + parseIssueUrl: parseLinearIssueUrl, probeCredential: (token) => linear.viewer(token).pipe( diff --git a/packages/issue-tracker-linear/src/shared/issueUrl.ts b/packages/issue-tracker-linear/src/shared/issueUrl.ts new file mode 100644 index 0000000000000..cf748e66e113f --- /dev/null +++ b/packages/issue-tracker-linear/src/shared/issueUrl.ts @@ -0,0 +1,14 @@ +import { IssueTrackerKind } from "@t3tools/contracts"; +import type { IssueLink } from "@t3tools/source-control-core/shared/definition"; + +export const LINEAR_TRACKER = IssueTrackerKind.make("linear"); +export const LINEAR_HOST = "linear.app"; + +/** `https://linear.app//issue/-[/]`; the team key is the scope. */ +export function parseLinearIssueUrl(url: URL): (IssueLink & { readonly workspace: string }) | null { + if (url.protocol !== "https:" || url.host.toLowerCase() !== LINEAR_HOST) return null; + const [, workspace, resource, key] = url.pathname.split("/"); + if (!workspace || resource !== "issue" || key === undefined) return null; + const scope = /^([A-Z][A-Z0-9_]*)-[1-9][0-9]*$/.exec(key)?.[1]; + return scope === undefined ? null : { host: LINEAR_HOST, workspace, scope, key }; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f1772ae8410fd..64f2adfcd956d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1525,6 +1525,9 @@ importers: '@t3tools/contracts': specifier: workspace:* version: link:../contracts + '@t3tools/issue-tracker-linear': + specifier: workspace:* + version: link:../issue-tracker-linear '@t3tools/provider-acp-registry': specifier: workspace:* version: link:../provider-acp-registry From e5ee77a9e7f5a6a2490fe9a89f6a9272b804a8be Mon Sep 17 00:00:00 2001 From: Jordi Wippert Date: Wed, 18 Nov 2026 22:45:21 +0100 Subject: [PATCH 3/6] fix(client-runtime): a Linear link from another workspace no longer opens a same-key issue Team keys repeat across Linear workspaces, so a link to ENG-12 in another workspace would read ENG-12 from the connected one. The server's resolveUrl compares the workspace in the issue's own URL; the client now does the same. On web the issue view says the issue is in another Linear workspace and offers to open it on Linear; on mobile the link opens in the browser. Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/native/useOpenPullRequest.ts | 19 +++++++++++++- .../chat/RightPanelSurfaceContent.tsx | 1 + .../src/components/issue/IssueDetailPanel.tsx | 14 +++++++++++ apps/web/src/components/issue/IssuesPage.tsx | 1 + .../client-runtime/src/issueLinks.test.ts | 25 ++++++++++++++++++- packages/client-runtime/src/issueLinks.ts | 14 +++++++++++ 6 files changed, 72 insertions(+), 2 deletions(-) diff --git a/apps/mobile/src/native/useOpenPullRequest.ts b/apps/mobile/src/native/useOpenPullRequest.ts index ee707e2bafa93..79f7c37881864 100644 --- a/apps/mobile/src/native/useOpenPullRequest.ts +++ b/apps/mobile/src/native/useOpenPullRequest.ts @@ -1,5 +1,8 @@ import { useNavigation, useRoute, StackActions } from "@react-navigation/native"; -import { resolveIssueLinkTarget } from "@t3tools/client-runtime/issue-links"; +import { + linksAnotherLinearWorkspace, + resolveIssueLinkTarget, +} from "@t3tools/client-runtime/issue-links"; import { nativePullRequestDestination, pullRequestCandidateForIssueLink, @@ -10,6 +13,7 @@ import { useProjects, useThreadShell } from "../state/entities"; import { tryOpenExternalUrl } from "../lib/openExternalUrl"; import { appAtomRegistry } from "../state/atom-registry"; import { environmentServerConfigsAtom } from "../state/server"; +import { issueEnvironment } from "../state/issues"; import { issueTrackerEnvironment } from "../state/issueTrackers"; import { composerPullRequests } from "../state/pull-requests"; import { useAtomQueryRunner } from "../state/use-atom-query-runner"; @@ -33,6 +37,10 @@ export function useNavigateToPullRequest(options?: { readonly replace?: boolean reportFailure: false, reportDefect: false, }); + const readIssue = useAtomQueryRunner(issueEnvironment.detail, { + reportFailure: false, + reportDefect: false, + }); return async (url: string, context: PullRequestContext | null) => { // Read at press time so a config push does not hand every link a new handler. const serverConfigs = appAtomRegistry.get(environmentServerConfigsAtom); @@ -52,10 +60,12 @@ export function useNavigateToPullRequest(options?: { readonly replace?: boolean }) : null; let issue = resolveIssue(); + let standalone = false; if (!issue && environmentId) { // Linear links resolve through the projects bound to a team in Settings. const trackers = await readTrackers({ environmentId, input: {} }); if (trackers._tag === "Success") issue = resolveIssue(trackers.value.bindings); + standalone = issue !== null; } if (!issue || !environmentId) return tryOpenExternalUrl(url, "pull-request"); const candidate = pullRequestCandidateForIssueLink(url, issue.ref); @@ -76,6 +86,13 @@ export function useNavigateToPullRequest(options?: { readonly replace?: boolean // A dropped connection says nothing about what the link names; the browser knows. if (isAtomCommandInterrupted(preview)) return tryOpenExternalUrl(url, "pull-request"); } + if (standalone) { + // Team keys repeat across Linear workspaces; another workspace's issue is not ours to show. + const detail = await readIssue({ environmentId, input: issue.ref }); + if (detail._tag === "Success" && linksAnotherLinearWorkspace(url, detail.value.url)) { + return tryOpenExternalUrl(url, "pull-request"); + } + } const issueParams = { environmentId, projectId: issue.ref.projectId, diff --git a/apps/web/src/components/chat/RightPanelSurfaceContent.tsx b/apps/web/src/components/chat/RightPanelSurfaceContent.tsx index 80f27c8dce568..11d5b0450a425 100644 --- a/apps/web/src/components/chat/RightPanelSurfaceContent.tsx +++ b/apps/web/src/components/chat/RightPanelSurfaceContent.tsx @@ -199,6 +199,7 @@ export function RightPanelSurfaceContent(props: { scope: surface.scope, key: surface.key, }} + linkUrl={surface.url} threadRef={threadRef} onSelectPullRequest={(reference) => { useRightPanelStore.getState().openPullRequest(threadRef, { diff --git a/apps/web/src/components/issue/IssueDetailPanel.tsx b/apps/web/src/components/issue/IssueDetailPanel.tsx index 20a9d7aa93cf8..8f4eef8adaeff 100644 --- a/apps/web/src/components/issue/IssueDetailPanel.tsx +++ b/apps/web/src/components/issue/IssueDetailPanel.tsx @@ -1,4 +1,5 @@ import { RegistryContext, useAtomValue } from "@effect/atom-react"; +import { linksAnotherLinearWorkspace } from "@t3tools/client-runtime/issue-links"; import { issueEventSentence, issueWriteAccess } from "@t3tools/client-runtime/issue-presentation"; import { createIssueCommentPager } from "@t3tools/client-runtime/state/issues"; import { @@ -465,10 +466,13 @@ export function IssueDetailPanel({ reference, threadRef = null, listEntry = null, + linkUrl, onSelectPullRequest, }: { environmentId: EnvironmentId; reference: IssueRef; + /** The link this issue was opened from, when a click in text opened it. */ + linkUrl?: string | undefined; /** The list row this issue was opened from, shown until the detail arrives. */ listEntry?: IssueListEntry | null; threadRef?: ScopedThreadRef | null; @@ -510,6 +514,16 @@ export function IssueDetailPanel({ return ; } + if (linkUrl !== undefined && linksAnotherLinearWorkspace(linkUrl, detail.url)) { + return ( + + ); + } + const timeline: ReadonlyArray = [ ...comments.map((c): TimelineItem => ({ kind: "comment", at: c.createdAt, comment: c })), ...detail.events.map((e): TimelineItem => ({ kind: "event", at: e.createdAt, event: e })), diff --git a/apps/web/src/components/issue/IssuesPage.tsx b/apps/web/src/components/issue/IssuesPage.tsx index bd8627a2e6689..6b37af9611854 100644 --- a/apps/web/src/components/issue/IssuesPage.tsx +++ b/apps/web/src/components/issue/IssuesPage.tsx @@ -788,6 +788,7 @@ export function IssuesPage() { scope: renderedSurface.scope, key: renderedSurface.key, }} + linkUrl={renderedSurface.url} onSelectPullRequest={(reference) => { useRightPanelStore.getState().openPullRequest(rightPanelRef, { projectId: reference.projectId, diff --git a/packages/client-runtime/src/issueLinks.test.ts b/packages/client-runtime/src/issueLinks.test.ts index 15455092c3cae..4c20688e8c85e 100644 --- a/packages/client-runtime/src/issueLinks.test.ts +++ b/packages/client-runtime/src/issueLinks.test.ts @@ -6,7 +6,7 @@ import { } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; -import { resolveIssueLinkTarget } from "./issueLinks.ts"; +import { linksAnotherLinearWorkspace, resolveIssueLinkTarget } from "./issueLinks.ts"; const project = (id: string, repository: string) => ({ @@ -105,3 +105,26 @@ describe("resolveIssueLinkTarget", () => { expect(resolveIssueLinkTarget({ url, projects })).toBeNull(); }); }); + +describe("linksAnotherLinearWorkspace", () => { + it.each([ + { + link: "https://linear.app/acme/issue/ENG-12", + issue: "https://linear.app/acme/issue/ENG-12/a-title", + expected: false, + }, + { + link: "https://linear.app/other/issue/ENG-12", + issue: "https://linear.app/acme/issue/ENG-12/a-title", + expected: true, + }, + { link: "https://linear.app/acme/issue/ENG-12", issue: "not a url", expected: true }, + { + link: "https://github.com/acme/web/issues/7", + issue: "https://github.com/acme/web/issues/7", + expected: false, + }, + ])("$link opening $issue is another workspace's: $expected", ({ link, issue, expected }) => { + expect(linksAnotherLinearWorkspace(link, issue)).toBe(expected); + }); +}); diff --git a/packages/client-runtime/src/issueLinks.ts b/packages/client-runtime/src/issueLinks.ts index 4b499e6c1d83f..9990fd39ef783 100644 --- a/packages/client-runtime/src/issueLinks.ts +++ b/packages/client-runtime/src/issueLinks.ts @@ -133,3 +133,17 @@ function resolveLinearIssueLink(input: { }, }; } + +/** + * Whether a Linear link names another workspace than the issue it opened. Team keys repeat across + * workspaces, so the connected one can hold an issue under the same key; only the issue's own + * URL says which workspace it is in, as in the server's `IssueService.resolveUrl`. Any link + * that is not a Linear issue link is never another workspace's. + */ +export function linksAnotherLinearWorkspace(linkUrl: string, issueUrl: string): boolean { + if (!URL.canParse(linkUrl)) return false; + const link = parseLinearIssueUrl(new URL(linkUrl)); + if (link === null) return false; + const issue = URL.canParse(issueUrl) ? parseLinearIssueUrl(new URL(issueUrl)) : null; + return issue?.workspace !== link.workspace; +} From 287f76fb14eed3b91db393b62d02ee731f38dabe Mon Sep 17 00:00:00 2001 From: Jordi Wippert Date: Wed, 18 Nov 2026 22:54:40 +0100 Subject: [PATCH 4/6] fix(web): translate the another-Linear-workspace issue state The issue view's message for a Linear link from another workspace gets its catalog entries in every locale, so the i18n check passes. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/i18n/translations/de.json | 3 +++ apps/web/src/i18n/translations/en.json | 3 +++ apps/web/src/i18n/translations/es.json | 3 +++ apps/web/src/i18n/translations/fr.json | 3 +++ apps/web/src/i18n/translations/ja.json | 3 +++ apps/web/src/i18n/translations/ko.json | 3 +++ apps/web/src/i18n/translations/pt-BR.json | 3 +++ apps/web/src/i18n/translations/ru.json | 3 +++ apps/web/src/i18n/translations/sv.json | 3 +++ apps/web/src/i18n/translations/zh.json | 3 +++ 10 files changed, 30 insertions(+) diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index 4c9f0f6d27e4f..4c320e967bc90 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -5678,6 +5678,9 @@ "b8a884177afea13c": "Es gibt mehr Personen, als hier aufgeführt sind.", "6081fdaabe34daf7": "Zugewiesen", "2d9b7c42374ecd04": "Dieses Issue konnte nicht geladen werden", + "f4a2cf1e37b0f65c": "Dieses Issue ist in einem anderen Linear-Workspace", + "ccbf4f5267dde5b8": "Das verbundene Linear-Konto hat ein Issue mit demselben Schlüssel, aber nicht dieses.", + "8e8867deed70a6c1": "Auf Linear öffnen", "217e1e7b60469736": "Issue-Status, {state}", "a98a269e3061a069": "{issue} auf {provider} öffnen", "c1ff5afd83b1e027": "Issue aktualisieren", diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index c40470b46e6ae..84d5ce98ae376 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -5679,6 +5679,9 @@ "b8a884177afea13c": "More people exist than are listed here.", "6081fdaabe34daf7": "Assigned", "2d9b7c42374ecd04": "Could not load this issue", + "f4a2cf1e37b0f65c": "This issue is in another Linear workspace", + "ccbf4f5267dde5b8": "The connected Linear account has an issue with the same key, not this one.", + "8e8867deed70a6c1": "Open on Linear", "217e1e7b60469736": "Issue state, {state}", "a98a269e3061a069": "Open {issue} on {provider}", "c1ff5afd83b1e027": "Refresh issue", diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index 68f63f589f51e..5e5c5ab2852d1 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -5677,6 +5677,9 @@ "b8a884177afea13c": "Hay más personas de las que se muestran aquí.", "6081fdaabe34daf7": "Asignado", "2d9b7c42374ecd04": "No se pudo cargar esta issue", + "f4a2cf1e37b0f65c": "Esta issue está en otro espacio de trabajo de Linear", + "ccbf4f5267dde5b8": "La cuenta de Linear conectada tiene una issue con la misma clave, pero no esta.", + "8e8867deed70a6c1": "Abrir en Linear", "217e1e7b60469736": "Estado de la issue, {state}", "a98a269e3061a069": "Abrir {issue} en {provider}", "c1ff5afd83b1e027": "Actualizar issue", diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index 442c22ed3a2d7..057aa8bb4ac81 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -5678,6 +5678,9 @@ "b8a884177afea13c": "Il existe plus de personnes que celles listées ici.", "6081fdaabe34daf7": "Assigné", "2d9b7c42374ecd04": "Impossible de charger ce ticket", + "f4a2cf1e37b0f65c": "Ce ticket se trouve dans un autre espace de travail Linear", + "ccbf4f5267dde5b8": "Le compte Linear connecté a un ticket avec la même clé, mais pas celui-ci.", + "8e8867deed70a6c1": "Ouvrir sur Linear", "217e1e7b60469736": "État du ticket, {state}", "a98a269e3061a069": "Ouvrir {issue} sur {provider}", "c1ff5afd83b1e027": "Actualiser le ticket", diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index c9417551b208c..2a064c1a95745 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -5660,6 +5660,9 @@ "b8a884177afea13c": "ここに表示されている以外にもユーザーがいます。", "6081fdaabe34daf7": "割り当て済み", "2d9b7c42374ecd04": "この Issue を読み込めませんでした", + "f4a2cf1e37b0f65c": "この Issue は別の Linear ワークスペースにあります", + "ccbf4f5267dde5b8": "接続中の Linear アカウントには同じキーの Issue がありますが、これとは別のものです。", + "8e8867deed70a6c1": "Linear で開く", "217e1e7b60469736": "Issue の状態、{state}", "a98a269e3061a069": "{provider} で {issue} を開く", "c1ff5afd83b1e027": "Issue を更新", diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index 362d29d071a87..b19296bee95f2 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -5658,6 +5658,9 @@ "b8a884177afea13c": "여기에 표시된 것보다 사용자가 더 있습니다.", "6081fdaabe34daf7": "지정됨", "2d9b7c42374ecd04": "이 이슈를 불러올 수 없습니다", + "f4a2cf1e37b0f65c": "이 이슈는 다른 Linear 워크스페이스에 있습니다", + "ccbf4f5267dde5b8": "연결된 Linear 계정에 같은 키의 이슈가 있지만 이 이슈는 아닙니다.", + "8e8867deed70a6c1": "Linear에서 열기", "217e1e7b60469736": "이슈 상태, {state}", "a98a269e3061a069": "{provider}에서 {issue} 열기", "c1ff5afd83b1e027": "이슈 새로 고침", diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index b598943e92383..7111d02da1954 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -5677,6 +5677,9 @@ "b8a884177afea13c": "Há mais pessoas do que as listadas aqui.", "6081fdaabe34daf7": "Atribuído", "2d9b7c42374ecd04": "Não foi possível carregar esta issue", + "f4a2cf1e37b0f65c": "Esta issue está em outro workspace do Linear", + "ccbf4f5267dde5b8": "A conta do Linear conectada tem uma issue com a mesma chave, mas não esta.", + "8e8867deed70a6c1": "Abrir no Linear", "217e1e7b60469736": "Estado da issue, {state}", "a98a269e3061a069": "Abrir {issue} no {provider}", "c1ff5afd83b1e027": "Atualizar issue", diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index a8a54a6500e59..7d17ab7557456 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -5677,6 +5677,9 @@ "b8a884177afea13c": "Людей больше, чем показано здесь.", "6081fdaabe34daf7": "Назначен", "2d9b7c42374ecd04": "Не удалось загрузить этот issue", + "f4a2cf1e37b0f65c": "Этот issue находится в другом рабочем пространстве Linear", + "ccbf4f5267dde5b8": "В подключённом аккаунте Linear есть issue с тем же ключом, но не этот.", + "8e8867deed70a6c1": "Открыть в Linear", "217e1e7b60469736": "Состояние issue: {state}", "a98a269e3061a069": "Открыть {issue} в {provider}", "c1ff5afd83b1e027": "Обновить issue", diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index adaf8566b6411..d73bc48c83ce8 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -5678,6 +5678,9 @@ "b8a884177afea13c": "Det finns fler personer än som listas här.", "6081fdaabe34daf7": "Tilldelad", "2d9b7c42374ecd04": "Kunde inte läsa in det här ärendet", + "f4a2cf1e37b0f65c": "Det här ärendet finns i en annan Linear-arbetsyta", + "ccbf4f5267dde5b8": "Det anslutna Linear-kontot har ett ärende med samma nyckel, men inte det här.", + "8e8867deed70a6c1": "Öppna på Linear", "217e1e7b60469736": "Ärendestatus, {state}", "a98a269e3061a069": "Öppna {issue} på {provider}", "c1ff5afd83b1e027": "Uppdatera ärende", diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index f386e717a0614..bb951d761400b 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -5684,6 +5684,9 @@ "b8a884177afea13c": "还有更多人员未在此列出。", "6081fdaabe34daf7": "已分配", "2d9b7c42374ecd04": "无法加载此 issue", + "f4a2cf1e37b0f65c": "此 issue 位于另一个 Linear 工作区", + "ccbf4f5267dde5b8": "已连接的 Linear 账户中有一个键相同的 issue,但不是这一个。", + "8e8867deed70a6c1": "在 Linear 上打开", "217e1e7b60469736": "issue 状态,{state}", "a98a269e3061a069": "在 {provider} 上打开 {issue}", "c1ff5afd83b1e027": "刷新 issue", From 10e74dbe9fb46d4fc86eade094ab45191c6ac1d3 Mon Sep 17 00:00:00 2001 From: Jordi Wippert Date: Wed, 18 Nov 2026 23:20:48 +0100 Subject: [PATCH 5/6] fix(mobile): only Linear links read tracker bindings, and an unchecked workspace goes to the browser An ordinary link no longer waits for the tracker connections read before it opens in the browser: the read runs only when the environment supports issues and the link names a Linear issue. A Linear issue whose detail read fails opens in the browser too, since the Issue screen would read it again by key without the workspace check. Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/native/useOpenPullRequest.ts | 12 ++++++++---- packages/client-runtime/src/issueLinks.test.ts | 17 ++++++++++++++++- packages/client-runtime/src/issueLinks.ts | 5 +++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/apps/mobile/src/native/useOpenPullRequest.ts b/apps/mobile/src/native/useOpenPullRequest.ts index 79f7c37881864..f385432c52c19 100644 --- a/apps/mobile/src/native/useOpenPullRequest.ts +++ b/apps/mobile/src/native/useOpenPullRequest.ts @@ -1,5 +1,6 @@ import { useNavigation, useRoute, StackActions } from "@react-navigation/native"; import { + isLinearIssueLink, linksAnotherLinearWorkspace, resolveIssueLinkTarget, } from "@t3tools/client-runtime/issue-links"; @@ -50,8 +51,11 @@ export function useNavigateToPullRequest(options?: { readonly replace?: boolean if (!destination) { // An issue link from the same text opens the issue; anything else leaves for the browser. const environmentId = context && EnvironmentId.make(context.environmentId); + const issuesSupported = + environmentId !== null && + serverConfigs.get(environmentId)?.environment.capabilities.issues === true; const resolveIssue = (trackerBindings?: IssueTrackerConnectionList["bindings"]) => - environmentId && serverConfigs.get(environmentId)?.environment.capabilities.issues === true + environmentId && issuesSupported ? resolveIssueLinkTarget({ url, projects: projects.filter((project) => project.environmentId === environmentId), @@ -61,7 +65,7 @@ export function useNavigateToPullRequest(options?: { readonly replace?: boolean : null; let issue = resolveIssue(); let standalone = false; - if (!issue && environmentId) { + if (!issue && environmentId && issuesSupported && isLinearIssueLink(url)) { // Linear links resolve through the projects bound to a team in Settings. const trackers = await readTrackers({ environmentId, input: {} }); if (trackers._tag === "Success") issue = resolveIssue(trackers.value.bindings); @@ -87,9 +91,9 @@ export function useNavigateToPullRequest(options?: { readonly replace?: boolean if (isAtomCommandInterrupted(preview)) return tryOpenExternalUrl(url, "pull-request"); } if (standalone) { - // Team keys repeat across Linear workspaces; another workspace's issue is not ours to show. + // Team keys repeat across Linear workspaces; an issue whose workspace is unconfirmed goes to the browser. const detail = await readIssue({ environmentId, input: issue.ref }); - if (detail._tag === "Success" && linksAnotherLinearWorkspace(url, detail.value.url)) { + if (detail._tag !== "Success" || linksAnotherLinearWorkspace(url, detail.value.url)) { return tryOpenExternalUrl(url, "pull-request"); } } diff --git a/packages/client-runtime/src/issueLinks.test.ts b/packages/client-runtime/src/issueLinks.test.ts index 4c20688e8c85e..890baa99346ba 100644 --- a/packages/client-runtime/src/issueLinks.test.ts +++ b/packages/client-runtime/src/issueLinks.test.ts @@ -6,7 +6,11 @@ import { } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; -import { linksAnotherLinearWorkspace, resolveIssueLinkTarget } from "./issueLinks.ts"; +import { + isLinearIssueLink, + linksAnotherLinearWorkspace, + resolveIssueLinkTarget, +} from "./issueLinks.ts"; const project = (id: string, repository: string) => ({ @@ -128,3 +132,14 @@ describe("linksAnotherLinearWorkspace", () => { expect(linksAnotherLinearWorkspace(link, issue)).toBe(expected); }); }); + +describe("isLinearIssueLink", () => { + it.each([ + { url: "https://linear.app/acme/issue/ENG-12/a-title", expected: true }, + { url: "https://linear.app/acme/project/roadmap", expected: false }, + { url: "https://docs.example.com/guide", expected: false }, + { url: "not a url", expected: false }, + ])("$url is a Linear issue link: $expected", ({ url, expected }) => { + expect(isLinearIssueLink(url)).toBe(expected); + }); +}); diff --git a/packages/client-runtime/src/issueLinks.ts b/packages/client-runtime/src/issueLinks.ts index 9990fd39ef783..df4419cf2a800 100644 --- a/packages/client-runtime/src/issueLinks.ts +++ b/packages/client-runtime/src/issueLinks.ts @@ -134,6 +134,11 @@ function resolveLinearIssueLink(input: { }; } +/** Whether a link names a Linear issue, so tracker bindings could open it. */ +export function isLinearIssueLink(url: string): boolean { + return URL.canParse(url) && parseLinearIssueUrl(new URL(url)) !== null; +} + /** * Whether a Linear link names another workspace than the issue it opened. Team keys repeat across * workspaces, so the connected one can hold an issue under the same key; only the issue's own From e9a99df53da11b17a37b8d70c5e83d214072fae1 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 19 Nov 2026 01:29:31 +0000 Subject: [PATCH 6/6] test(client-runtime): drop the isLinearIssueLink wrapper table Co-Authored-By: Claude Opus 5.5 --- packages/client-runtime/src/issueLinks.test.ts | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/packages/client-runtime/src/issueLinks.test.ts b/packages/client-runtime/src/issueLinks.test.ts index 890baa99346ba..4c20688e8c85e 100644 --- a/packages/client-runtime/src/issueLinks.test.ts +++ b/packages/client-runtime/src/issueLinks.test.ts @@ -6,11 +6,7 @@ import { } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; -import { - isLinearIssueLink, - linksAnotherLinearWorkspace, - resolveIssueLinkTarget, -} from "./issueLinks.ts"; +import { linksAnotherLinearWorkspace, resolveIssueLinkTarget } from "./issueLinks.ts"; const project = (id: string, repository: string) => ({ @@ -132,14 +128,3 @@ describe("linksAnotherLinearWorkspace", () => { expect(linksAnotherLinearWorkspace(link, issue)).toBe(expected); }); }); - -describe("isLinearIssueLink", () => { - it.each([ - { url: "https://linear.app/acme/issue/ENG-12/a-title", expected: true }, - { url: "https://linear.app/acme/project/roadmap", expected: false }, - { url: "https://docs.example.com/guide", expected: false }, - { url: "not a url", expected: false }, - ])("$url is a Linear issue link: $expected", ({ url, expected }) => { - expect(isLinearIssueLink(url)).toBe(expected); - }); -});