diff --git a/bun.lock b/bun.lock
index d765ccf9b68..23e6b6285ee 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1349,6 +1349,7 @@
"@shepherdjerred/loaded": "workspace:*",
"@shepherdjerred/ops-model": "workspace:*",
"@shepherdjerred/test-postgres": "workspace:*",
+ "@tanstack/react-form": "catalog:",
"@tanstack/react-query": "catalog:",
"@tanstack/react-router": "catalog:",
"@trpc/client": "catalog:",
@@ -9060,6 +9061,8 @@
"@shepherdjerred/golink/@sentry/bun": ["@sentry/bun@11.18.0", "", { "dependencies": { "@sentry/bundler-plugins": "11.18.0", "@sentry/conventions": "^0.36.0", "@sentry/core": "11.18.0", "@sentry/node": "11.18.0", "@sentry/server-runtime-injection": "11.18.0", "@sentry/server-utils": "11.18.0" } }, "sha512-ESEkTStPghccjZKruy/sqzOdQeDjOMJsqEehyxyoElNK5oxpBfxqfBR6cTvQOFnTZ39pTvknDFBkZHj0Unx5rw=="],
+ "@shepherdjerred/golink/@tanstack/react-form": ["@tanstack/react-form@1.33.6", "", { "dependencies": { "@tanstack/form-core": "1.33.6", "@tanstack/react-store": "^0.11.0" }, "peerDependencies": { "@tanstack/react-start": "*", "react": "^17.0.0 || ^18.0.0 || ^19.0.0" }, "optionalPeers": ["@tanstack/react-start"] }, "sha512-4JRcQZ0uQrsvkVEd2uZ/d6xIb711Jj/+MQjBLCFpK29xvSIRzz1h6YrA+BsQ+ZjQZNYoOugp1idLmoWpelUSgQ=="],
+
"@shepherdjerred/incidents/react-router": ["react-router@8.4.0", "", { "dependencies": { "@remix-run/route-pattern": "^0.22.1", "cookie-es": "^3.1.1" }, "peerDependencies": { "react": ">=19.2.7", "react-dom": ">=19.2.7" }, "optionalPeers": ["react-dom"] }, "sha512-JtydAkBvU9UTEe5qNC+POhu+ZBNM7rlKY2IegwXc7Idj7xfRG16x5RZrw3mju+XlqBxfvb2ky9P3jUp9WyWC1g=="],
"@shepherdjerred/llm-runtime/ai": ["ai@7.0.183", "", { "dependencies": { "@ai-sdk/gateway": "4.0.156", "@ai-sdk/provider": "4.0.39", "@ai-sdk/provider-utils": "5.0.85" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-rrPZNiuOKr8L6j9acxrWpE/lKWgR+rYNHDYr9bOvfMLM8RlsX75WMJsMw4LBPZkX6tdjFL8fiLXhTKN29wkkYQ=="],
@@ -10128,6 +10131,8 @@
"@shepherdjerred/golink/@sentry/bun/@sentry/server-utils": ["@sentry/server-utils@11.18.0", "", { "dependencies": { "@opentelemetry/api": "^1.9.1", "@sentry/conventions": "^0.36.0", "@sentry/core": "11.18.0" } }, "sha512-1ny+6qT8Hyt9EWplbAcf28wiFS82jiLCGwy8PQeq2IHm8lxsGbRkohAcp3hfRHZUsyiSGOVBcN3ofORLZvxSyg=="],
+ "@shepherdjerred/golink/@tanstack/react-form/@tanstack/form-core": ["@tanstack/form-core@1.33.6", "", { "dependencies": { "@tanstack/devtools-event-client": "^0.5.1", "@tanstack/pacer-lite": "^0.1.1", "@tanstack/store": "^0.11.0" } }, "sha512-kyJN+qYVIxv4dXatQzKkay++NwEDkwS2hmZe80lRGxs4i+AbWKAucbKPndYgwSczbEoZms2VRqNeR+WnM4jucg=="],
+
"@shepherdjerred/llm-runtime/ai/@ai-sdk/gateway": ["@ai-sdk/gateway@4.0.156", "", { "dependencies": { "@ai-sdk/provider": "4.0.39", "@ai-sdk/provider-utils": "5.0.85", "@vercel/oidc": "3.2.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-Nv1ILpLYNDlIV/beyo6Uc6jZcwTDzLMiSqer4PUEmIHqyOceLHf58lv1bfntAJ0xZxaBa9BtYDOv3/Msu0mQrQ=="],
"@shepherdjerred/monarch/ai/@ai-sdk/gateway": ["@ai-sdk/gateway@4.0.156", "", { "dependencies": { "@ai-sdk/provider": "4.0.39", "@ai-sdk/provider-utils": "5.0.85", "@vercel/oidc": "3.2.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-Nv1ILpLYNDlIV/beyo6Uc6jZcwTDzLMiSqer4PUEmIHqyOceLHf58lv1bfntAJ0xZxaBa9BtYDOv3/Msu0mQrQ=="],
@@ -10750,6 +10755,8 @@
"@shepherdjerred/golink/@sentry/bun/@sentry/node/@sentry/opentelemetry": ["@sentry/opentelemetry@11.18.0", "", { "dependencies": { "@sentry/conventions": "^0.36.0", "@sentry/core": "11.18.0" }, "peerDependencies": { "@opentelemetry/api": "^1.9.0" } }, "sha512-f5cyOW/cayhmFBWgVaJIeVJ+VLi0tB0rxaNjMBb8eEKAKMBoqCngfEIOeMVeurrTRlGZ0A/525YEnBbfdTCmmg=="],
+ "@shepherdjerred/golink/@tanstack/react-form/@tanstack/form-core/@tanstack/devtools-event-client": ["@tanstack/devtools-event-client@0.5.1", "", {}, "sha512-MiBx6Ybr65MFatCnk8IJzhGxd4hvsvEap4aT0gXOC274rV4hm0UPNHxznB5KGYtu84aXrIAsJEBElqzdPe+eeg=="],
+
"@shepherdjerred/tracker/@sentry/bun/@sentry/bundler-plugins/dotenv": ["dotenv@17.4.2", "", {}, "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw=="],
"@shepherdjerred/tracker/@sentry/bun/@sentry/bundler-plugins/oxc-parser": ["oxc-parser@0.152.0", "", { "dependencies": { "@oxc-project/types": "^0.152.0" }, "optionalDependencies": { "@oxc-parser/binding-android-arm-eabi": "0.152.0", "@oxc-parser/binding-android-arm64": "0.152.0", "@oxc-parser/binding-darwin-arm64": "0.152.0", "@oxc-parser/binding-darwin-x64": "0.152.0", "@oxc-parser/binding-freebsd-x64": "0.152.0", "@oxc-parser/binding-linux-arm-gnueabihf": "0.152.0", "@oxc-parser/binding-linux-arm-musleabihf": "0.152.0", "@oxc-parser/binding-linux-arm64-gnu": "0.152.0", "@oxc-parser/binding-linux-arm64-musl": "0.152.0", "@oxc-parser/binding-linux-ppc64-gnu": "0.152.0", "@oxc-parser/binding-linux-riscv64-gnu": "0.152.0", "@oxc-parser/binding-linux-riscv64-musl": "0.152.0", "@oxc-parser/binding-linux-s390x-gnu": "0.152.0", "@oxc-parser/binding-linux-x64-gnu": "0.152.0", "@oxc-parser/binding-linux-x64-musl": "0.152.0", "@oxc-parser/binding-openharmony-arm64": "0.152.0", "@oxc-parser/binding-win32-arm64-msvc": "0.152.0", "@oxc-parser/binding-win32-ia32-msvc": "0.152.0", "@oxc-parser/binding-win32-x64-msvc": "0.152.0" } }, "sha512-ZztsZgaCWmPeKYMdoTT5e0oV/oxD1NeLWNR3kAtr/G707cUPYaaozRlVDHLCGnszHJRszN9mJwmPNpqgwloC0A=="],
diff --git a/packages/golink/eslint-suppressions.json b/packages/golink/eslint-suppressions.json
index b72e289d0a6..0967ef424bc 100644
--- a/packages/golink/eslint-suppressions.json
+++ b/packages/golink/eslint-suppressions.json
@@ -1,32 +1 @@
-{
- "src/client/app.tsx": {
- "@typescript-eslint/no-deprecated": {
- "count": 5
- }
- },
- "src/client/directory-sections.tsx": {
- "@typescript-eslint/no-deprecated": {
- "count": 1
- }
- },
- "src/client/link-dialogs.tsx": {
- "@typescript-eslint/no-deprecated": {
- "count": 6
- }
- },
- "src/client/links-card.tsx": {
- "@typescript-eslint/no-deprecated": {
- "count": 4
- }
- },
- "src/client/links-table.tsx": {
- "@typescript-eslint/no-deprecated": {
- "count": 4
- }
- },
- "src/client/shell.tsx": {
- "@typescript-eslint/no-deprecated": {
- "count": 1
- }
- }
-}
+{}
diff --git a/packages/golink/index.html b/packages/golink/index.html
index 955983c20d8..74ee0c408fd 100644
--- a/packages/golink/index.html
+++ b/packages/golink/index.html
@@ -6,8 +6,18 @@
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
-
-
Go links
+
+
+
+ Links · Go links
{
void navigate({ to: "/", search: {}, replace: true });
}, [navigate]);
- const [formMode, setFormMode] = useState({ kind: "create" });
- const [shortValue, setShortValue] = useState("");
- const [targetValue, setTargetValue] = useState("");
- const [shortErrorText, setShortErrorText] = useState(INITIAL_SHORT_ERROR);
- const [targetErrorText, setTargetErrorText] = useState(INITIAL_TARGET_ERROR);
- const [isSubmitting, setIsSubmitting] = useState(false);
- const [mutationError, setMutationError] = useState(null);
+
+ const [formRequest, setFormRequest] = useState(null);
const [statusMessage, setStatusMessage] = useState(null);
const [actionError, setActionError] = useState(null);
-
const [query, setQuery] = useState("");
const [kindFilter, setKindFilter] = useState("all");
- const [copiedShort, setCopiedShort] = useState(null);
const [pendingDelete, setPendingDelete] = useState(null);
const [deletingShort, setDeletingShort] = useState(null);
-
- const formElementRef = useRef(null);
- const shortInputRef = useRef(null);
- const targetInputRef = useRef(null);
- const formDialogRef = useRef(null);
- const deleteDialogRef = useRef(null);
const searchInputRef = useRef(null);
- const copyResetTimerRef = useRef<
- ReturnType | undefined
- >(undefined);
-
- const shellRef = useCallback((node: HTMLDivElement | null) => {
- if (node === null) {
- return;
- }
- // On the document, so `/` works while focus is on the page body too.
- const onKeyDown = (event: KeyboardEvent): void => {
- if (!isSearchShortcut(event)) {
- return;
- }
- event.preventDefault();
- searchInputRef.current?.focus();
- searchInputRef.current?.select();
- };
- document.addEventListener("keydown", onKeyDown);
-
- return () => {
- document.removeEventListener("keydown", onKeyDown);
- if (copyResetTimerRef.current !== undefined) {
- globalThis.clearTimeout(copyResetTimerRef.current);
- }
- };
- }, []);
-
- const formRef = useCallback((node: HTMLFormElement | null) => {
- formElementRef.current = node;
- if (node === null) {
- return;
- }
- return bindFormValidation(node);
- }, []);
+ useSearchShortcut(searchInputRef);
const writesEnabled = directory?.writesEnabled === true;
const links = useMemo(() => directory?.links ?? [], [directory]);
@@ -139,36 +85,18 @@ export function App({
);
}, [kindFilter, links, query]);
- const openDialog = (mode: FormMode, short: string, target: string): void => {
- setFormMode(mode);
- setShortValue(short);
- setTargetValue(target);
- setShortErrorText(INITIAL_SHORT_ERROR);
- setTargetErrorText(INITIAL_TARGET_ERROR);
- setMutationError(null);
+ const openForm = (mode: FormMode, short: string, target: string): void => {
setStatusMessage(null);
setActionError(null);
- if (formElementRef.current !== null) {
- resetFormValidationState(formElementRef.current);
- }
- showModalFromFocus(formDialogRef.current);
- // The values above land on the next render; select once they have.
- globalThis.setTimeout(() => {
- const field =
- short === "" && mode.kind === "create"
- ? shortInputRef.current
- : targetInputRef.current;
- field?.focus();
- field?.select();
- }, 0);
+ setFormRequest({ mode, short, target });
};
const handleNewLink = (prefill = ""): void => {
- openDialog({ kind: "create" }, prefill, "");
+ openForm({ kind: "create" }, prefill, "");
};
const handleEditLink = (item: LinkItem): void => {
- openDialog({ kind: "edit", short: item.short }, item.short, item.targetUrl);
+ openForm({ kind: "edit", short: item.short }, item.short, item.targetUrl);
};
const handleOverrideLink = (item: LinkItem): void => {
@@ -176,7 +104,7 @@ export function App({
handleEditLink(item);
return;
}
- openDialog(
+ openForm(
{
kind: "override",
short: item.short,
@@ -188,45 +116,12 @@ export function App({
);
};
- const focusSearch = (): void => {
- searchInputRef.current?.focus();
- searchInputRef.current?.select();
- };
-
- const submitUpsertForm = async (): Promise => {
- const form = formElementRef.current;
- if (form === null || isSubmitting || !writesEnabled) {
- return;
- }
- if (shortInputRef.current !== null) {
- setShortErrorText(syncShortInputValidity(shortInputRef.current));
- }
- if (targetInputRef.current !== null) {
- setTargetErrorText(syncTargetInputValidity(targetInputRef.current));
- }
- if (!form.checkValidity()) {
- focusFirstInvalidField(form);
- return;
- }
-
- setIsSubmitting(true);
- setMutationError(null);
- setStatusMessage(null);
-
- try {
- const saved = await saveLink.mutateAsync({
- short: normalizeShortSlug(shortValue),
- targetUrl: targetValue.trim(),
- });
- clearMissingSlug();
- formDialogRef.current?.close();
- setStatusMessage(`Saved go/${saved.short} → ${saved.targetUrl}`);
- await reloadDirectory();
- } catch (error) {
- setMutationError(errorMessage(error, "Unable to save shortlink."));
- } finally {
- setIsSubmitting(false);
- }
+ const save = async (short: string, targetUrl: string): Promise => {
+ const saved = await saveLink.mutateAsync({ short, targetUrl });
+ clearMissingSlug();
+ setFormRequest(null);
+ setStatusMessage(`Saved go/${saved.short} → ${saved.targetUrl}`);
+ await reloadDirectory();
};
const confirmDelete = async (): Promise => {
@@ -245,154 +140,113 @@ export function App({
setActionError(errorMessage(error, `Unable to delete go/${item.short}.`));
} finally {
setDeletingShort(null);
- deleteDialogRef.current?.close();
- }
- };
-
- const handleCopyLink = async (short: string): Promise => {
- const shareUrl = new URL(
- `/${encodeURIComponent(short)}`,
- globalThis.location.origin,
- ).href;
- try {
- await globalThis.navigator.clipboard.writeText(shareUrl);
- setCopiedShort(short);
- if (copyResetTimerRef.current !== undefined) {
- globalThis.clearTimeout(copyResetTimerRef.current);
- }
- copyResetTimerRef.current = globalThis.setTimeout(() => {
- setCopiedShort(null);
- }, 1800);
- } catch {
- setStatusMessage(`Shortlink URL: ${shareUrl}`);
+ setPendingDelete(null);
}
};
return (
-
-
-
- }
- >
-
-
+
+
+ {
+ setQuery(event.target.value);
+ }}
+ />
+ {writesEnabled ? (
{
handleNewLink();
}}
>
-
+
New link
) : directory === null ? null : (
- Read-only
- )
- }
- />
-
- {activeMissingSlug !== null && (
- {
- handleNewLink(activeMissingSlug);
- }}
- onDismiss={clearMissingSlug}
- />
- )}
-
- {actionError !== null && (
-
- {actionError}
-
- )}
-
- {statusMessage ?? ""}
-
+ Read-only
+ )}
+
+ }
+ />
-
-
- ({
- items: filteredLinks,
- totalCount: all.length,
- }))}
+ {activeMissingSlug !== null && (
+ {
- void directoryQuery.refetch();
- }}
- onCopy={(short) => {
- void handleCopyLink(short);
- }}
- onEdit={handleEditLink}
- onOverride={handleOverrideLink}
- onDelete={(item) => {
- setPendingDelete(item);
- showModalFromFocus(deleteDialogRef.current);
+ onCreate={() => {
+ handleNewLink(activeMissingSlug);
}}
+ onDismiss={clearMissingSlug}
/>
+ )}
+
+ {actionError !== null && (
+
+ {actionError}
+
+ )}
+ {statusMessage !== null && (
+
+ {statusMessage}
+
+ )}
+
+ {statusMessage ?? ""}
+
+
+
-
-
-
+ ({
+ items: filteredLinks,
+ totalCount: all.length,
+ }))}
+ writesEnabled={writesEnabled}
+ deletingShort={deletingShort}
+ onRetry={() => {
+ void directoryQuery.refetch();
+ }}
+ onEdit={handleEditLink}
+ onOverride={handleOverrideLink}
+ onDelete={setPendingDelete}
+ />
+
+
+
{
- void submitUpsertForm();
+ onSave={save}
+ onClose={() => {
+ setFormRequest(null);
}}
/>
{
@@ -402,6 +256,6 @@ export function App({
setPendingDelete(null);
}}
/>
-
+
);
}
diff --git a/packages/golink/src/client/client.test.tsx b/packages/golink/src/client/client.test.tsx
index f2d23701c30..bd368bb007e 100644
--- a/packages/golink/src/client/client.test.tsx
+++ b/packages/golink/src/client/client.test.tsx
@@ -3,10 +3,10 @@ import { describe, expect, test } from "vitest";
import { createThemeStore } from "@shepherdjerred/console-ui";
import type { LinkItem } from "#shared/contract.ts";
import { DeleteConfirmDialog } from "./link-dialogs.tsx";
-import { LinksCard, summaryItems } from "./links-card.tsx";
+import { LinksSection, summaryFigures } from "./links-card.tsx";
import { Loaded } from "@shepherdjerred/loaded";
import { LinksTable } from "./links-table.tsx";
-import { GolinkSidebar } from "./shell.tsx";
+import { GolinkShell } from "./shell.tsx";
const noop = (): void => undefined;
@@ -50,9 +50,7 @@ function renderTable(
items={items}
totalCount={totalCount}
writesEnabled={writesEnabled}
- copiedShort={null}
deletingShort={null}
- onCopy={noop}
onEdit={noop}
onOverride={noop}
onDelete={noop}
@@ -66,9 +64,9 @@ describe("LinksTable", () => {
const body = html.slice(html.indexOf(""));
expect(body.match(//gu)).toHaveLength(LINKS.length);
expect(body).toContain("go/docs");
- expect(body).toContain(">Manual<");
- expect(body).toContain(">Tailnet Ingress<");
- expect(body).toContain(">Platform Site<");
+ expect(body).toContain("Manual");
+ expect(body).toContain("Tailnet Ingress");
+ expect(body).toContain("Platform Site");
});
test("names the shadowed destination and truncates with a title", () => {
@@ -98,32 +96,32 @@ describe("LinksTable", () => {
});
test("renders an empty state for a filter and for an empty directory", () => {
- expect(renderTable(true, [], LINKS.length)).toBe(
- 'No shortlinks match the current filter.
',
- );
+ const filtered = renderTable(true, [], LINKS.length);
+ expect(filtered).toContain('data-kind="empty"');
+ expect(filtered).toContain("No shortlinks match the current filter.");
expect(renderTable(true, [], 0)).toContain("No shortlinks yet.");
});
- test("is a Hub data table whose cells carry their phone-card labels", () => {
+ test("is a plain ui-table whose cells carry their phone labels", () => {
const html = renderTable(true);
expect(html).toMatch(
- /^