@devries-cameron20 / t3code Mirror · read-only / commits / f8665a1c21
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 04:15 UTC

fix(web): a prompt link opened from a thread no longer lands in that thread (#19326)

Igor Makowski committed Oct 18, 2026 at 21:16 UTC f8665a1c212a5157315cba2d6ed3d89bb4ae56da
3 files changed +23
apps/web/src/components/promptLinks/ThreadLinkPrompt.tsx
+3
@@ -3,6 +3,7 @@ import { parseThreadLinkPrompt, withoutPromptLinkParams } from "@t3tools/shared/
3 import { useLocation, useNavigate } from "@tanstack/react-router";
4 import { useEffect } from "react";
5
6 +import { isThreadRoutePathname } from "../../threadRoutes";
7 import { stackedThreadToast, toastManager } from "../ui/toast";
8 import { placeLinkedPrompt } from "./linkedPrompt";
9
@@ -20,6 +21,8 @@ export function ThreadLinkPrompt({ threadRef }: { readonly threadRef: ScopedThre
21 });
22
23 useEffect(() => {
24 + // A pending navigation shows the next location while the params still name this thread.
25 + if (!isThreadRoutePathname(location.pathname, threadRef)) return;
26 if (!new URLSearchParams(location.search).has("prompt")) return;
27 if (!handledLinkKeys.has(location.key)) {
28 handledLinkKeys.add(location.key);
apps/web/src/threadRoutes.test.ts
+14
@@ -6,6 +6,7 @@ import { DraftId } from "./composerDraftStore";
6 import {
7 buildDraftThreadRouteParams,
8 buildThreadRouteParams,
9 + isThreadRoutePathname,
10 isThreadRouteSnapshotAuthoritative,
11 resolveActiveThreadRouteRef,
12 resolveThreadRouteRenderState,
@@ -45,6 +46,19 @@ describe("threadRoutes", () => {
46 expect(resolveThreadRouteRef({ threadId: "thread-1" })).toBeNull();
47 });
48
49 + it("matches only the thread's own route pathname", () => {
50 + const ref = scopeThreadRef("env-1" as never, ThreadId.make("thread-1"));
51 +
52 + expect(isThreadRoutePathname("/env-1/thread-1", ref)).toBe(true);
53 + expect(isThreadRoutePathname("/env-1/thread-1/", ref)).toBe(true);
54 + // A pending navigation away from the thread already shows these locations.
55 + expect(isThreadRoutePathname("/new", ref)).toBe(false);
56 + expect(isThreadRoutePathname("/env-1/thread-2", ref)).toBe(false);
57 + expect(isThreadRoutePathname("/env-2/thread-1", ref)).toBe(false);
58 + expect(isThreadRoutePathname("/draft/thread-1", ref)).toBe(false);
59 + expect(isThreadRoutePathname("/env-1/thread-1/extra", ref)).toBe(false);
60 + });
61 +
62 it("builds canonical draft route params from a draft id", () => {
63 expect(buildDraftThreadRouteParams(DraftId.make("draft-1"))).toEqual({
64 draftId: "draft-1",
apps/web/src/threadRoutes.ts
+6
@@ -52,6 +52,12 @@ export function buildThreadRouteParams(ref: ScopedThreadRef): {
52 };
53 }
54
55 +/** Whether a (decoded) location pathname is `ref`'s own thread route, `/$environmentId/$threadId`. */
56 +export function isThreadRoutePathname(pathname: string, ref: ScopedThreadRef): boolean {
57 + const { environmentId, threadId } = buildThreadRouteParams(ref);
58 + return pathname.replace(/\/$/, "") === `/${environmentId}/${threadId}`;
59 +}
60 +
61 export function buildDraftThreadRouteParams(draftId: DraftId): {
62 draftId: DraftId;
63 } {