GeezerVison is showing github.com — feat(web): webhook URLs say who can reach them, using the shared addr… · pingdotgg/t3code@1882ec2
File treeExpand file treeCollapse file tree Open diff view settings apps/web/src/components/settings
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/settings/ScheduledTasksSettings.tsx +4-9Lines changed: 4 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,6 +42,7 @@ import { | 42 | 42 | sortProviderInstanceEntries, | 43 | 43 | } from "../../providerInstances"; | 44 | 44 | import { requestConfirmDialog } from "../../confirmDialog"; | | 45 | +import { webhookAddress } from "@t3tools/client-runtime/webhook-address"; | 45 | 46 | import { useCopyToClipboard } from "../../hooks/useCopyToClipboard"; | 46 | 47 | import { | 47 | 48 | useEnvironment, | @@ -62,7 +63,6 @@ import { | 62 | 63 | scheduleFromDraft, | 63 | 64 | scheduledTaskDefaultModel, | 64 | 65 | taskToDraft, | 65 | | - webhookUrl, | 66 | 66 | type DraftState, | 67 | 67 | type ScheduleMode, | 68 | 68 | type WorkspaceMode, | @@ -671,7 +671,7 @@ function WebhookEndpointField({ | 671 | 671 | if (!task || !endpoint) { | 672 | 672 | return <p className="text-sm text-muted-foreground">The URL appears after you save.</p>; | 673 | 673 | } | 674 | | - const url = webhookUrl(endpoint, httpBaseUrl); | | 674 | + const { address: url, copyable, note } = webhookAddress(endpoint, httpBaseUrl); | 675 | 675 | const rotateUrl = async () => { | 676 | 676 | const confirmed = | 677 | 677 | (await requestConfirmDialog("Rotate this webhook URL?\nThe current URL stops working.", { | @@ -708,7 +708,7 @@ function WebhookEndpointField({ | 708 | 708 | variant="outline" | 709 | 709 | type="button" | 710 | 710 | // A bare path is not a URL a sender can call. | 711 | | - disabled={!url.startsWith("http")} | | 711 | + disabled={!copyable} | 712 | 712 | onClick={() => copyToClipboard(url, undefined)} | 713 | 713 | > | 714 | 714 | <CopyIcon /> | @@ -724,12 +724,7 @@ function WebhookEndpointField({ | 724 | 724 | Rotate | 725 | 725 | </Button> | 726 | 726 | </div> | 727 | | - {endpoint.url === null ? ( | 728 | | - <p className="text-xs text-muted-foreground"> | 729 | | - Link this environment to T3 Connect for a public URL. This address works wherever the | 730 | | - environment is reachable. | 731 | | - </p> | 732 | | - ) : null} | | 727 | + {note !== null ? <p className="text-xs text-muted-foreground">{note}</p> : null} | 733 | 728 | </div> | 734 | 729 | ); | 735 | 730 | } | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/settings/scheduledTasksSettings.logic.test.ts -12Lines changed: 0 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,7 +21,6 @@ import { | 21 | 21 | matchesScheduledTaskScope, | 22 | 22 | scheduleFromDraft, | 23 | 23 | taskToDraft, | 24 | | - webhookUrl, | 25 | 24 | } from "./scheduledTasksSettings.logic"; | 26 | 25 |
| 27 | 26 | const laptopId = EnvironmentId.make("laptop"); | @@ -195,17 +194,6 @@ describe("webhook scheduled tasks", () => { | 195 | 194 | expect(draft.signatureHeader).toBe("x-hub-signature-256"); | 196 | 195 | expect(scheduleFromDraft(draft)).toEqual({ type: "webhook", signature: null }); | 197 | 196 | }); | 198 | | - | 199 | | - it("prefers the Connect URL and otherwise resolves the path on the environment", () => { | 200 | | - const endpoint = { path: "/api/hooks/id/token", url: null, hasSecret: false }; | 201 | | - expect(webhookUrl({ ...endpoint, url: "https://relay/v1/hooks/e/id/token" }, null)).toBe( | 202 | | - "https://relay/v1/hooks/e/id/token", | 203 | | - ); | 204 | | - expect(webhookUrl(endpoint, "https://box.tailnet.ts.net:3773/")).toBe( | 205 | | - "https://box.tailnet.ts.net:3773/api/hooks/id/token", | 206 | | - ); | 207 | | - expect(webhookUrl(endpoint, null)).toBe("/api/hooks/id/token"); | 208 | | - }); | 209 | 197 | }); | 210 | 198 |
| 211 | 199 | describe("scheduled task model defaults", () => { | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/settings/scheduledTasksSettings.logic.ts -10Lines changed: 0 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 | ScheduledTaskId, | 5 | 5 | type ScheduledTask, | 6 | 6 | type ScheduledTaskUpsertSchedule, | 7 | | - type ScheduledTaskWebhookEndpoint, | 8 | 7 | type ModelSelection, | 9 | 8 | type RuntimeMode, | 10 | 9 | type ProviderInteractionMode, | @@ -118,15 +117,6 @@ export function scheduleFromDraft(draft: DraftState): ScheduledTaskUpsertSchedul | 118 | 117 | }; | 119 | 118 | } | 120 | 119 |
| 121 | | -/** The address a sender should call: the public Connect URL, else the path on this environment's address. */ | 122 | | -export function webhookUrl( | 123 | | - endpoint: ScheduledTaskWebhookEndpoint, | 124 | | - httpBaseUrl: string | null, | 125 | | -): string { | 126 | | - if (endpoint.url !== null) return endpoint.url; | 127 | | - return httpBaseUrl ? new URL(endpoint.path, httpBaseUrl).href : endpoint.path; | 128 | | -} | 129 | | - | 130 | 120 | export function taskToDraft(task: ScheduledTask): DraftState { | 131 | 121 | const schedule = task.schedule; | 132 | 122 | const weekdays = | |
|