TypeScript
refactor(web): remove obsolete pull request link opener (#9983)
Julius Marmingeba873b8181c3
diff --git a/apps/web/src/lib/openPullRequestLink.test.ts b/apps/web/src/lib/openPullRequestLink.test.tsindex 6029c9bb3da..ad4971d331d 100644--- a/apps/web/src/lib/openPullRequestLink.test.ts+++ b/apps/web/src/lib/openPullRequestLink.test.ts@@ -1,14 +1,12 @@-import { describe, expect, it, vi } from "vite-plus/test";+import { describe, expect, it } from "vite-plus/test";import {changeRequestRepositoryUrl,findProjectForChangeRequest,gitHubPullRequestBrowserUrl,matchesLinkedPullRequestUrl,- openPullRequestLink,parseChangeRequestUrl,pullRequestCandidateUrlFromReferenceAutolink,- PullRequestLinkOpenError,shouldOpenPullRequestExternally,} from "./openPullRequestLink";import { ProjectId, type RepositoryIdentity } from "@t3tools/contracts";@@ -184,33 +182,6 @@ describe("matchesLinkedPullRequestUrl", () => {});});-describe("openPullRequestLink", () => {- it("opens the requested pull request URL", async () => {- const openExternal = vi.fn(async () => undefined);- const targetUrl = "https://github.com/pingdotgg/t3code/pull/123";-- await openPullRequestLink({ openExternal }, targetUrl);-- expect(openExternal).toHaveBeenCalledExactlyOnceWith(targetUrl);- });-- it("reports bridge failures with a safe target origin", async () => {- const cause = new Error("desktop shell unavailable");- const targetUrl = "https://github.com/pingdotgg/t3code/pull/123?token=secret";- const openExternal = vi.fn(async () => Promise.reject(cause));-- const result = openPullRequestLink({ openExternal }, targetUrl);-- await expect(result).rejects.toEqual(- new PullRequestLinkOpenError({- targetOrigin: "https://github.com",- cause,- }),- );- await expect(result).rejects.not.toHaveProperty("message", expect.stringContaining("secret"));- });-});-describe("shouldOpenPullRequestExternally", () => {it("uses the browser for command-click and control-click", () => {expect(shouldOpenPullRequestExternally({ metaKey: true, ctrlKey: false })).toBe(true);diff --git a/apps/web/src/lib/openPullRequestLink.ts b/apps/web/src/lib/openPullRequestLink.tsindex 0050c62bc72..2d46e3984fd 100644--- a/apps/web/src/lib/openPullRequestLink.ts+++ b/apps/web/src/lib/openPullRequestLink.ts@@ -1,12 +1,10 @@import type {EnvironmentId,- LocalApi,RepositoryIdentity,ScopedThreadRef,ThreadLinkedPullRequest,} from "@t3tools/contracts";import { useNavigate } from "@tanstack/react-router";-import * as Schema from "effect/Schema";import { type MouseEvent, useCallback } from "react";import { pullRequestHostOf, type SourceControlProviderKind } from "@t3tools/contracts";@@ -19,41 +17,6 @@ import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";import { useProjects, useServerConfigs } from "../state/entities";import { usePrimaryEnvironmentId } from "../state/environments";-export class PullRequestLinkOpenError extends Schema.TaggedErrorClass<PullRequestLinkOpenError>()(- "PullRequestLinkOpenError",- {- targetOrigin: Schema.NullOr(Schema.String),- cause: Schema.Defect(),- },-) {- static fromCause(targetUrl: string, cause: unknown): PullRequestLinkOpenError {- let targetOrigin: string | null = null;- try {- targetOrigin = new URL(targetUrl).origin;- } catch {- // Keep malformed URLs out of diagnostics while preserving the open failure below.- }- return new PullRequestLinkOpenError({ targetOrigin, cause });- }-- override get message(): string {- return this.targetOrigin === null- ? "Unable to open pull request link."- : `Unable to open pull request link at ${this.targetOrigin}.`;- }-}--export async function openPullRequestLink(- shell: Pick<LocalApi["shell"], "openExternal">,- targetUrl: string,-): Promise<void> {- try {- await shell.openExternal(targetUrl);- } catch (cause) {- throw PullRequestLinkOpenError.fromCause(targetUrl, cause);- }-}-/** Builds a GitHub URL that remains available when the pull request API cannot be read. */export function gitHubPullRequestBrowserUrl(identity: RepositoryIdentity | null | undefined,