From 31d33e8ebc6be2204569032d4143eeaa1026f5fd Mon Sep 17 00:00:00 2001 From: Bil0000 <62337003+Bil0000@users.noreply.github.com> Date: Tue, 17 Nov 2026 19:34:49 +0100 Subject: [PATCH 1/5] feat(web): show linked issues beside thread pull requests --- .../BranchToolbarBranchSelector.tsx | 15 +--- .../src/components/ChatView.browser.test.tsx | 84 +++++++++++++++++++ apps/web/src/components/ChatView.tsx | 7 +- apps/web/src/components/CommandPalette.tsx | 8 +- apps/web/src/components/RightPanelTabs.tsx | 10 +-- .../chat/ThreadDetailsIssueRows.tsx | 16 ++-- .../chat/ThreadDetailsPrRow.browser.test.tsx | 6 +- .../pullRequest/ThreadPullRequestsPanel.tsx | 27 ++++-- .../components/sidebar/SidebarThreadRow.tsx | 37 +++++++- apps/web/test/fakeEnvironment.ts | 17 +++- docs/user/source-control.md | 13 +-- 11 files changed, 192 insertions(+), 48 deletions(-) diff --git a/apps/web/src/components/BranchToolbarBranchSelector.tsx b/apps/web/src/components/BranchToolbarBranchSelector.tsx index a58f5a76d6935..998b39d409d1d 100644 --- a/apps/web/src/components/BranchToolbarBranchSelector.tsx +++ b/apps/web/src/components/BranchToolbarBranchSelector.tsx @@ -887,20 +887,7 @@ export function BranchToolbarBranchSelector({ /> ) : null} {displayMode === "panel" ? ( - { - event.stopPropagation(); - useRightPanelStore.getState().openIssue(threadRef, { - projectId: link.projectId, - tracker: link.tracker, - host: link.host, - scope: link.scope, - key: link.key, - url: link.url, - }); - }} - /> + ) : null} diff --git a/apps/web/src/components/ChatView.browser.test.tsx b/apps/web/src/components/ChatView.browser.test.tsx index a0458f9e80280..40c26f02185a0 100644 --- a/apps/web/src/components/ChatView.browser.test.tsx +++ b/apps/web/src/components/ChatView.browser.test.tsx @@ -2,10 +2,13 @@ import { createMemoryHistory } from "@tanstack/react-router"; import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment"; import { EnvironmentId, + IssueTrackerKind, ORCHESTRATION_V2_WS_METHODS, RunId, ThreadId, WS_METHODS, + type IssueDetail, + type ThreadIssueLink, } from "@t3tools/contracts"; import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings"; import { @@ -109,6 +112,87 @@ vi.mock(import("~/rpc/requestLatencyState"), async (original) => ({ trackRpcRequestSent: () => {}, })); +it("opens a linked issue from an inactive thread's sidebar badge", async () => { + const first = threadWithHistory("issue-first", 1); + const linked = threadWithHistory("issue-linked", 1); + const issue: ThreadIssueLink = { + projectId: PROJECT_ID, + tracker: IssueTrackerKind.make("github"), + host: "github.com", + scope: "example/project", + key: "123", + url: "https://github.com/example/project/issues/123", + source: "manual", + linkedAt: "2026-01-01T00:00:00.000Z", + displayKey: "#123", + title: "Add keyboard support", + }; + using _environment = installFakeEnvironment([first, { ...linked, issues: [issue] }]); + const liveTitle = "Add keyboard shortcuts to the sidebar"; + using _detail = answerRpc(WS_METHODS.issuesDetail, () => + Effect.succeed({ + ...issue, + title: liveTitle, + author: null, + state: { category: "open", name: "Open" }, + createdAt: issue.linkedAt, + updatedAt: issue.linkedAt, + closedAt: null, + assignees: [], + labels: [], + commentCount: 0, + projectTitle: "render", + writable: false, + capabilities: { + create: false, + edit: false, + comment: false, + labels: false, + assignees: false, + reactions: false, + templates: false, + linkedPullRequests: false, + events: false, + search: false, + }, + viewerPermissions: { + setState: false, + comment: false, + edit: false, + labels: false, + assignees: false, + }, + states: [], + viewer: null, + body: "", + comments: [], + commentsCursor: null, + events: [], + linkedPullRequests: [], + } satisfies IssueDetail), + ); + __setClientSettingsForTests({ + ...DEFAULT_CLIENT_SETTINGS, + onboardingCompletedAt: "2026-01-01T00:00:00.000Z", + }); + await page.viewport(1400, 900); + const router = getRouter( + createMemoryHistory({ initialEntries: [`/${ENVIRONMENT_ID}/${first.id}`] }), + ); + await router.load(); + await using _app = await render(, { + // AppRoot brings its own router. + router: false, + }); + const name = "Issue #123: Add keyboard support"; + await userEvent.click(page.getByRole("button", { name })); + await userEvent.click( + page.getByRole("region", { name: "Linked issues" }).getByRole("link", { name }), + ); + expect(router.history.location.pathname).toBe(`/${ENVIRONMENT_ID}/${linked.id}`); + await expect.element(page.getByRole("heading", { name: liveTitle })).toBeVisible(); +}); + it("a machine chip stashed in one thread restores with its machine in another", async () => { const other = threadWithHistory("thread-stash-restore", 1); const asking = threadWithQuestion("thread-stash-question", "Which file should change?"); diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 1a50e7fdfa6b3..fb3ecabaf8526 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2003,6 +2003,9 @@ export default function ChatView(props: ChatViewProps) { const visiblePullRequestCount = visiblePullRequests.length; const pullRequestsSurfaceAvailable = isServerThread && supportsThreadPullRequests && visiblePullRequestCount > 0; + const linkedItemsSurfaceAvailable = + pullRequestsSurfaceAvailable || + (isServerThread && (activeThreadShell?.issues?.length ?? 0) > 0); const { state: deviceState, loaded: deviceStateLoaded } = useDeviceState( activeThreadRef?.environmentId ?? null, ); @@ -2427,7 +2430,7 @@ export default function ChatView(props: ChatViewProps) { canMaximizeRightPanel, rightPanelMaximized, supportsPullRequests, - pullRequestsSurfaceAvailable, + pullRequestsSurfaceAvailable: linkedItemsSurfaceAvailable, gitCwd, activeProjectCwd, onDiffPanelOpen, @@ -4044,7 +4047,7 @@ export default function ChatView(props: ChatViewProps) { diffAvailable={isServerThread && isGitRepo} filesAvailable={activeProject !== null} pullRequestAvailable={pullRequestSurfaceAvailable} - pullRequestsAvailable={pullRequestsSurfaceAvailable} + pullRequestsAvailable={linkedItemsSurfaceAvailable} deviceAvailable={activeThreadRef !== null} sideChatAvailable={sideChat.available} sideChatDisabledReason={sideChatDisabledReason} diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx index ff0770444ff6a..148b08d9e600e 100644 --- a/apps/web/src/components/CommandPalette.tsx +++ b/apps/web/src/components/CommandPalette.tsx @@ -1478,9 +1478,11 @@ function OpenCommandPaletteDialog(props: { actionItems.push({ kind: "action", value: "action:open-thread-pull-requests", - searchTerms: ["pull requests", "linked", "stack", "prs"], - title: "Show linked pull requests", - disabled: visibleThreadPullRequests(activeThread.pullRequests).length === 0, + searchTerms: ["pull requests", "issues", "linked", "stack", "prs"], + title: "Show linked items", + disabled: + visibleThreadPullRequests(activeThread.pullRequests).length === 0 && + !activeThread.issues?.length, icon: , run: async () => { useRightPanelStore.getState().open(threadRef, "pull-requests"); diff --git a/apps/web/src/components/RightPanelTabs.tsx b/apps/web/src/components/RightPanelTabs.tsx index 5e18356f4830d..093ee6935dccc 100644 --- a/apps/web/src/components/RightPanelTabs.tsx +++ b/apps/web/src/components/RightPanelTabs.tsx @@ -183,7 +183,7 @@ const SURFACE_DISABLED_REASONS = { files: "Files are only available when a project is open.", diff: "Diff is only available for server threads in Git repositories.", pullRequest: "This thread's branch has no pull request yet.", - pullRequests: "No linked pull requests are available for this thread.", + pullRequests: "This thread has no linked items.", device: "Devices are only available from a thread.", sideChat: "Side chats start after the first message.", } as const; @@ -208,7 +208,7 @@ const SURFACE_UNAVAILABLE_HINTS = { files: "Available when a project is open.", diff: "Available for Git repositories.", pullRequest: "No pull request on this branch yet.", - pullRequests: "No linked pull requests available.", + pullRequests: "No linked items available.", device: "Available from a thread.", sideChat: "Available after the first message.", } as const; @@ -384,7 +384,7 @@ function RightPanelEmptyState(props: { onClick: props.onAddPullRequest, }, { - label: "Linked pull requests", + label: "Linked items", icon: PullRequestGlyph.link, shortcut: "L", available: props.pullRequestsAvailable, @@ -595,7 +595,7 @@ function surfaceTitle( case "pull-request": return `#${surface.number}`; case "pull-requests": - return "Pull requests"; + return "Linked items"; case "issue": // A git host numbers its issues; a tracker with keys of its own, such as Linear, names them. return /^\d+$/.test(surface.key) ? `#${surface.key}` : surface.key; @@ -1178,7 +1178,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) { onClick: props.onAddPullRequest, }, { - label: "Linked pull requests", + label: "Linked items", icon: PullRequestGlyph.link, shortcut: "L", available: props.pullRequestsAvailable, diff --git a/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx b/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx index b529cd6afe6a1..745c856a7a172 100644 --- a/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx +++ b/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx @@ -1,7 +1,7 @@ -import { threadIssueKeyOf, type ThreadIssueLink } from "@t3tools/contracts"; -import type { MouseEvent as ReactMouseEvent } from "react"; +import { threadIssueKeyOf, type ScopedThreadRef, type ThreadIssueLink } from "@t3tools/contracts"; import { cn } from "~/lib/utils"; +import { useRightPanelStore } from "~/rightPanelStore"; import { IssueGlyph } from "../issue/issuePresentation"; import { ThreadDetailsControl } from "./ThreadDetailsControl"; @@ -17,10 +17,10 @@ import { */ export function ThreadDetailsIssueRows({ links, - onOpenLink, + threadRef, }: { links: ReadonlyArray; - onOpenLink: (event: ReactMouseEvent, link: ThreadIssueLink) => void; + threadRef: ScopedThreadRef; }) { if (links.length === 0) return null; return ( @@ -29,8 +29,14 @@ export function ThreadDetailsIssueRows({ } aria-label={`Issue ${link.displayKey}: ${link.title}`} - onClick={(event) => onOpenLink(event, link)} + onClick={(event) => { + event.stopPropagation(); + if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; + event.preventDefault(); + useRightPanelStore.getState().openIssue(threadRef, link); + }} > diff --git a/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx b/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx index 1c3fa1a3899fc..133d63b4b260a 100644 --- a/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx +++ b/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx @@ -382,12 +382,12 @@ it("names a linked issue row by its kind, number and title, not its URL", async title: "Sidebar flickers on resize", }, ]} - onOpenLink={vi.fn()} + threadRef={threadRef} />, ); }); - const row = [...screen.container.querySelectorAll("button")].find((button) => - button.textContent?.includes("Sidebar flickers on resize"), + const row = [...screen.container.querySelectorAll("a")].find((link) => + link.textContent?.includes("Sidebar flickers on resize"), )!; const name = row.getAttribute("aria-label") ?? row.textContent ?? ""; expect(name).not.toContain("https://"); diff --git a/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx b/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx index 8a3c76b632655..4ed42bd9aa1d4 100644 --- a/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx +++ b/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx @@ -39,6 +39,7 @@ import { PullRequestsUnavailableState } from "./PullRequestsUnavailableState"; import { threadEnvironment } from "~/state/threads"; import { useAtomCommand } from "~/state/use-atom-command"; import { RelativeTime } from "~/components/RelativeTime"; +import { ThreadDetailsIssueRows } from "../chat/ThreadDetailsIssueRows"; import { Button } from "../ui/button"; import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu"; import { MiddleTruncate } from "../ui/middle-truncate"; @@ -382,8 +383,8 @@ export function ThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread if (configs.get(threadRef.environmentId) === undefined) { return ( ); } @@ -392,6 +393,7 @@ export function ThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThreadRef }) { const thread = useThreadShell(threadRef); + const issues = thread?.issues ?? []; const projects = useProjects(); const environmentProjects = projects .filter((project) => project.environmentId === threadRef.environmentId) @@ -481,7 +483,7 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread primaryEnvironmentId, }; - if (linkCount === 0) { + if (linkCount === 0 && issues.length === 0) { return (
@@ -507,6 +509,21 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread data={lines} keyExtractor={lineKey} extraData={rowInputs} + ListHeaderComponent={ + issues.length > 0 ? ( + <> +
+

Issues

+ +
+ {linkCount > 0 ? ( +

+ Pull requests +

+ ) : null} + + ) : null + } renderItem={({ item: line }) => (
- {openCount} open · {linkCount} linked + {linkCount > 0 ? `${openCount} open · ${linkCount} linked` : null} {lastSynced ? ( <> {" · synced "} @@ -541,7 +558,7 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
diff --git a/apps/web/src/components/sidebar/SidebarThreadRow.tsx b/apps/web/src/components/sidebar/SidebarThreadRow.tsx index 20f97159fdb2c..e156fd6db56ea 100644 --- a/apps/web/src/components/sidebar/SidebarThreadRow.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadRow.tsx @@ -126,6 +126,7 @@ import { MiddleTruncate } from "../ui/middle-truncate"; import { ActivityShimmerOverlay } from "../chat/TimelineRowParts"; import { observeVisibleAnimation } from "~/lib/visibleAnimation"; import { useThreadHasUnsentDraft } from "../../composerDraftStore"; +import { IssueGlyph } from "../issue/issuePresentation"; // The fields thread rows show. Provider status pushes refresh `checkedAt`, // status and auth on every provider; leaving those out keeps each @@ -1089,7 +1090,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP const prBadgeShape = supportsMultiplePullRequests ? resolveThreadPullRequestBadge(thread.pullRequests) : null; - const handlePrListClick = () => { + const openLinkedItems = () => { useRightPanelStore.getState().open(threadRef, "pull-requests"); if (!props.isRouteThread) onThreadActivate(threadRef); }; @@ -1102,10 +1103,39 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP number={pr?.number ?? currentLinkedPr?.number} url={pr?.url ?? currentLinkedPr?.url} status={prStatus} - onOpenList={handlePrListClick} + onOpenList={openLinkedItems} onOpenPullRequest={handlePrClick} /> ) : null; + const firstIssue = thread.issues?.[0]; + const issueCount = thread.issues?.length ?? 0; + const issueLabel = + issueCount === 1 && firstIssue + ? `Issue ${firstIssue.displayKey}: ${firstIssue.title}` + : `${issueCount} linked issues`; + const issueBadge = firstIssue ? ( + + event.stopPropagation()} + onClick={(event) => { + event.stopPropagation(); + openLinkedItems(); + }} + /> + } + > + + + {issueCount === 1 ? firstIssue.displayKey : issueCount} + + + {issueLabel} + + ) : null; const terminalStatusIcon = ( +{formatDiffCount(diff.insertions)}{" "} @@ -1292,6 +1324,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP {multiline ? titleLineIcons : null} {pinIndicator} {multiline ? null : terminalStatusIcon} + {multiline ? null : issueBadge} {isRegeneratingTitle ? ( Regenerating title diff --git a/apps/web/test/fakeEnvironment.ts b/apps/web/test/fakeEnvironment.ts index 42afe2ef59911..91336c9bb5a6b 100644 --- a/apps/web/test/fakeEnvironment.ts +++ b/apps/web/test/fakeEnvironment.ts @@ -103,9 +103,15 @@ export const CLAUDE_PROVIDER = { }; const decodeServerConfig = Schema.decodeUnknownSync(ServerConfig); -const makeServerConfig = (providers: ReadonlyArray): ServerConfig => ({ +const makeServerConfig = ( + providers: ReadonlyArray, + supportsIssues = false, +): ServerConfig => ({ ...decodeServerConfig({ - environment: descriptor, + environment: { + ...descriptor, + capabilities: { ...descriptor.capabilities, issues: supportsIssues }, + }, auth, cwd: "/workspace/render", keybindingsConfigPath: "/workspace/.t3/keybindings.json", @@ -229,6 +235,7 @@ export interface FakeThread { readonly modelSelection?: ModelSelection; /** The first is the thread's active provider thread. */ readonly providerThreads?: ReadonlyArray; + readonly issues?: OrchestrationV2ThreadShell["issues"]; readonly runs: ReadonlyArray; readonly items: ReadonlyArray; readonly runtimeRequests?: OrchestrationV2ThreadProjection["runtimeRequests"]; @@ -316,6 +323,7 @@ function shellOf(thread: FakeThread): OrchestrationV2ThreadShell { branch: "main", worktreePath: null, activeProviderThreadId: thread.providerThreads?.[0]?.id ?? null, + ...(thread.issues === undefined ? {} : { issues: thread.issues }), lineage: { rootThreadId: thread.sideChatOf ?? thread.id, parentThreadId: thread.sideChatOf ?? null, @@ -573,7 +581,10 @@ export function installFakeEnvironment( ): Disposable { threads = fixtures; baseServerConfig = { - ...makeServerConfig(options?.providers ?? [CODEX_PROVIDER]), + ...makeServerConfig( + options?.providers ?? [CODEX_PROVIDER], + fixtures.some((thread) => (thread.issues?.length ?? 0) > 0), + ), keybindings: options?.keybindings ?? DEFAULT_RESOLVED_KEYBINDINGS, }; dispatched = []; diff --git a/docs/user/source-control.md b/docs/user/source-control.md index f1a1454ff8dcc..69be5175c25d2 100644 --- a/docs/user/source-control.md +++ b/docs/user/source-control.md @@ -312,7 +312,7 @@ and their marks follow the same rules as on web and desktop. ## Linked pull requests A thread can hold several pull requests, including reviews from another repository on the same host. -Use **Link pull request** in the command palette or **Linked pull requests** panel, or right-click a +Use **Link pull request** in the command palette or **Linked items** panel, or right-click a pull request link in the conversation. Creating a pull request from Git actions links it automatically, and so does an agent creating one with `gh pr create` or `glab mr create`. Agents can link other pull requests with the `link_pull_request` tool. @@ -322,10 +322,10 @@ on the Pull requests page, **Link to thread** lets you search for an active thre also lists the threads that link to it, including archived threads, so you can return to their context. Thread badges show a stack's layer count or the current review number with a count of additional -links. Clicking a badge with more than one review opens the **Linked pull requests** panel. On mobile, the Git overview lists linked reviews and their stacks; tap a review to open it. +links. Clicking a badge with more than one review opens the **Linked items** panel. On mobile, the Git overview lists linked reviews and their stacks; tap a review to open it. Linking and unlinking are available in the web and desktop clients. -The **Linked pull requests** panel lists every review and groups stacks. Unlink a review from its +The **Linked items** panel lists every review and groups stacks. Unlink a review from its row menu. An unlinked stack layer stays out of later syncs. Open linked reviews refresh on the server; closed reviews refresh periodically so reopening one on the host is detected. Merged reviews refresh when requested. Settling a thread refreshes its open and closed reviews once; after that they stop refreshing until you unsettle it. With **Auto-settle merged threads** enabled, a thread can settle after every linked @@ -343,7 +343,7 @@ failed reads in a row, or when you press Stop on the thread. A rate limit only p Settling or archiving a thread also ends all its watches. Unsettle the thread before starting a new watch. Watching a pull request again does not repeat check or conflict news its last watch already reported; unlinking the pull request clears that. Subagents cannot watch pull requests; the thread that delegated to them does. To start or stop -it yourself, use the row menu in the **Linked pull requests** panel. In the thread details card, a +it yourself, use the row menu in the **Linked items** panel. In the thread details card, a watched pull request shows an eye; click it to stop watching. A watched thread counts as working while the pull request still has checks running, so it stays in @@ -377,8 +377,9 @@ allow it. An issue read through a project that does not own its repository is sh An issue can be kept with a thread the way a pull request can: open it beside the thread (issue links in the conversation open there) and use **Link to this thread** in its header; **Unlink** -undoes it. Linked issues are listed in the thread's details beside its pull requests. Agents link the -issues they work on with the `link_issue` tool. +undoes it. Click the issue badge in the thread sidebar to see its issues and pull requests in +**Linked items**. Select an issue there to open it beside the thread. Agents link the issues they +work on with the `link_issue` tool. Writing to a tracker over a remote connection requires the `source-control:write` scope. From 5755aaa421e45f8fc66670c716404a480a26d593 Mon Sep 17 00:00:00 2001 From: Bil0000 <62337003+Bil0000@users.noreply.github.com> Date: Tue, 17 Nov 2026 20:32:54 +0100 Subject: [PATCH 2/5] feat(web): show more detail for linked issues --- .../src/components/ChatView.browser.test.tsx | 29 +++- .../chat/ThreadDetailsIssueRows.tsx | 156 ++++++++++++++---- .../chat/ThreadDetailsPrRow.browser.test.tsx | 19 ++- .../pullRequest/ThreadPullRequestsPanel.tsx | 4 +- .../components/sidebar/SidebarThreadRow.tsx | 20 ++- 5 files changed, 177 insertions(+), 51 deletions(-) diff --git a/apps/web/src/components/ChatView.browser.test.tsx b/apps/web/src/components/ChatView.browser.test.tsx index 40c26f02185a0..9bdf0e44fa256 100644 --- a/apps/web/src/components/ChatView.browser.test.tsx +++ b/apps/web/src/components/ChatView.browser.test.tsx @@ -27,6 +27,7 @@ import "~/components/ChatView"; import { DraftId, useComposerDraftStore } from "~/composerDraftStore"; import { selectThreadDiffPanelSelection, useDiffPanelStore } from "~/diffPanelStore"; import { __setClientSettingsForTests } from "~/hooks/useSettings"; +import stylesheet from "~/index.css?inline"; import { environmentContextRecord } from "~/lib/composerContextRecords"; import { startWorkspaceFocus } from "~/lib/workspaceFocus"; import { usePromptStashStore } from "~/promptStashStore"; @@ -113,6 +114,10 @@ vi.mock(import("~/rpc/requestLatencyState"), async (original) => ({ })); it("opens a linked issue from an inactive thread's sidebar badge", async () => { + const style = document.createElement("style"); + style.textContent = stylesheet; + document.head.append(style); + using _style = { [Symbol.dispose]: () => style.remove() }; const first = threadWithHistory("issue-first", 1); const linked = threadWithHistory("issue-linked", 1); const issue: ThreadIssueLink = { @@ -133,14 +138,14 @@ it("opens a linked issue from an inactive thread's sidebar badge", async () => { Effect.succeed({ ...issue, title: liveTitle, - author: null, + author: { login: "sam", name: null, avatarUrl: null }, state: { category: "open", name: "Open" }, createdAt: issue.linkedAt, updatedAt: issue.linkedAt, closedAt: null, assignees: [], labels: [], - commentCount: 0, + commentCount: 3, projectTitle: "render", writable: false, capabilities: { @@ -185,10 +190,22 @@ it("opens a linked issue from an inactive thread's sidebar badge", async () => { router: false, }); const name = "Issue #123: Add keyboard support"; - await userEvent.click(page.getByRole("button", { name })); - await userEvent.click( - page.getByRole("region", { name: "Linked issues" }).getByRole("link", { name }), - ); + const badge = page.getByRole("button", { name }); + await userEvent.hover(badge); + const previewLink = page.getByRole("link", { name: `Issue #123: ${liveTitle}` }); + await userEvent.hover(previewLink.getByText("sam", { exact: true })); + await expect.element(previewLink).toBeVisible(); + const contextMenu = new MouseEvent("contextmenu", { bubbles: true, cancelable: true }); + await act(() => previewLink.element().dispatchEvent(contextMenu)); + expect(contextMenu.defaultPrevented).toBe(false); + await userEvent.click(badge); + const issueRow = page + .getByRole("region", { name: "Linked issues" }) + .getByRole("link", { name: `Issue #123: ${liveTitle}` }); + await expect.element(issueRow.getByRole("img", { name: "Open" })).toBeVisible(); + await expect.element(issueRow.getByRole("img", { name: "3 comments" })).toBeVisible(); + await expect.element(issueRow.getByText("example/project")).toBeVisible(); + await userEvent.click(issueRow); expect(router.history.location.pathname).toBe(`/${ENVIRONMENT_ID}/${linked.id}`); await expect.element(page.getByRole("heading", { name: liveTitle })).toBeVisible(); }); diff --git a/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx b/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx index 745c856a7a172..772388057c91f 100644 --- a/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx +++ b/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx @@ -1,49 +1,137 @@ import { threadIssueKeyOf, type ScopedThreadRef, type ThreadIssueLink } from "@t3tools/contracts"; +import { MessageSquareIcon } from "lucide-react"; +import type { MouseEvent } from "react"; import { cn } from "~/lib/utils"; import { useRightPanelStore } from "~/rightPanelStore"; +import { useServerConfigs } from "~/state/entities"; +import { issueEnvironment } from "~/state/issues"; +import { useEnvironmentQuery } from "~/state/query"; -import { IssueGlyph } from "../issue/issuePresentation"; -import { ThreadDetailsControl } from "./ThreadDetailsControl"; import { - THREAD_DETAILS_PANEL_ICON_CLASS, - THREAD_DETAILS_PANEL_LABEL_CLASS, -} from "./threadDetailsPanelStyles"; + IssueGlyph, + issueStatePresentation, + issueTrackerPresentation, +} from "../issue/issuePresentation"; +import { + PULL_REQUEST_ROW_CLASS, + PULL_REQUEST_ROW_NUMBER_CLASS, + PullRequestRowLines, +} from "../pullRequest/PullRequestListRow"; +import { PullRequestActorLabel } from "../pullRequest/pullRequestPresentation"; +import { ThreadDetailsControl } from "./ThreadDetailsControl"; -/** - * The thread details panel's issue rows, one per linked issue, beside the pull request rows. A - * row names the issue as it was when linked and opens it in the right panel, which reads its - * live state. - */ -export function ThreadDetailsIssueRows({ - links, +function LinkedIssueRow({ + link, threadRef, + compact, + onOpen, }: { - links: ReadonlyArray; + link: ThreadIssueLink; threadRef: ScopedThreadRef; + compact: boolean; + onOpen: (() => void) | undefined; }) { - if (links.length === 0) return null; - return ( + const { environmentId } = threadRef; + const configs = useServerConfigs(); + const { projectId, tracker, host, scope, key } = link; + const detail = useEnvironmentQuery( + configs.get(environmentId)?.environment.capabilities.issues === true + ? issueEnvironment.detail({ environmentId, input: { projectId, tracker, host, scope, key } }) + : null, + ).data; + const trackerPresentation = issueTrackerPresentation(tracker); + const state = detail === null ? null : issueStatePresentation(detail.state); + const Icon = state?.Icon ?? IssueGlyph.issue; + const title = detail?.title ?? link.title; + const anchorProps = { + href: link.url, + target: "_blank", + rel: "noopener noreferrer", + "aria-label": `Issue ${link.displayKey}: ${title}`, + onClick: (event: MouseEvent) => { + event.stopPropagation(); + if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; + event.preventDefault(); + useRightPanelStore.getState().openIssue(threadRef, link); + onOpen?.(); + }, + }; + const lines = ( <> - {links.map((link) => ( - } - aria-label={`Issue ${link.displayKey}: ${link.title}`} - onClick={(event) => { - event.stopPropagation(); - if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; - event.preventDefault(); - useRightPanelStore.getState().openIssue(threadRef, link); - }} - > - - - {link.displayKey}: {link.title} - - - ))} + + {link.displayKey}} + title={title} + status={ + detail !== null && detail.commentCount > 0 ? ( + + + {detail.commentCount} + + ) : null + } + meta={ + <> + {detail?.author ? ( + + ) : null} + + {scope} + + } + updatedAt={detail?.updatedAt ?? link.linkedAt} + /> ); + return compact ? ( + }> + {lines} + + ) : ( + + {lines} + + ); +} + +export function ThreadDetailsIssueRows({ + links, + threadRef, + compact = true, + onOpen, +}: { + links: ReadonlyArray; + threadRef: ScopedThreadRef; + compact?: boolean; + onOpen?: () => void; +}) { + return links.map((link) => ( + + )); } diff --git a/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx b/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx index 133d63b4b260a..a5398a3f6c925 100644 --- a/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx +++ b/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx @@ -74,14 +74,17 @@ vi.mock(import("~/state/query"), async (importOriginal) => ({ select(AsyncResult.success(queryData()))) as never, useEnvironmentQueryIsNewer: () => true, useEnvironmentQueryRefresh: () => ({ refresh: vi.fn(), isPending: () => false }), - useEnvironmentQuery: (() => ({ - data: { - code: { additions: 1, deletions: 0 }, - tests: { additions: 0, deletions: 0 }, - mocks: { additions: 0, deletions: 0 }, - generated: { additions: 0, deletions: 0 }, - docs: { additions: 7, deletions: 3 }, - }, + useEnvironmentQuery: ((atom: unknown) => ({ + data: + atom === null + ? null + : { + code: { additions: 1, deletions: 0 }, + tests: { additions: 0, deletions: 0 }, + mocks: { additions: 0, deletions: 0 }, + generated: { additions: 0, deletions: 0 }, + docs: { additions: 7, deletions: 3 }, + }, isPending: false, })) as never, })); diff --git a/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx b/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx index 4ed42bd9aa1d4..18dad4c4eba5b 100644 --- a/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx +++ b/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx @@ -512,9 +512,9 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread ListHeaderComponent={ issues.length > 0 ? ( <> -
+

Issues

- +
{linkCount > 0 ? (

diff --git a/apps/web/src/components/sidebar/SidebarThreadRow.tsx b/apps/web/src/components/sidebar/SidebarThreadRow.tsx index e156fd6db56ea..28c51cd74e3dd 100644 --- a/apps/web/src/components/sidebar/SidebarThreadRow.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadRow.tsx @@ -126,6 +126,7 @@ import { MiddleTruncate } from "../ui/middle-truncate"; import { ActivityShimmerOverlay } from "../chat/TimelineRowParts"; import { observeVisibleAnimation } from "~/lib/visibleAnimation"; import { useThreadHasUnsentDraft } from "../../composerDraftStore"; +import { ThreadDetailsIssueRows } from "../chat/ThreadDetailsIssueRows"; import { IssueGlyph } from "../issue/issuePresentation"; // The fields thread rows show. Provider status pushes refresh `checkedAt`, @@ -1133,7 +1134,24 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP {issueCount === 1 ? firstIssue.displayKey : issueCount} - {issueLabel} + event.stopPropagation()} + > +
+ { + if (!props.isRouteThread) onThreadActivate(threadRef); + }} + /> +
+
) : null; const terminalStatusIcon = ( From 0a2b8fc8f3f1fba235312eadb7c113a60e8c3682 Mon Sep 17 00:00:00 2001 From: Bil0000 <62337003+Bil0000@users.noreply.github.com> Date: Tue, 17 Nov 2026 21:43:39 +0100 Subject: [PATCH 3/5] fix(web): match linked issue badges and cards to pull requests --- .../src/components/ChatView.browser.test.tsx | 53 ++++++---- .../chat/ThreadDetailsIssueRows.tsx | 96 +++++++++++-------- .../chat/ThreadDetailsPrRow.browser.test.tsx | 54 ++--------- .../components/sidebar/SidebarThreadRow.tsx | 16 +++- apps/web/src/state/issues.ts | 25 ++++- .../client-runtime/src/state/runtime.test.ts | 8 +- packages/client-runtime/src/state/runtime.ts | 33 ++++--- 7 files changed, 165 insertions(+), 120 deletions(-) diff --git a/apps/web/src/components/ChatView.browser.test.tsx b/apps/web/src/components/ChatView.browser.test.tsx index 9bdf0e44fa256..e77e177f7f709 100644 --- a/apps/web/src/components/ChatView.browser.test.tsx +++ b/apps/web/src/components/ChatView.browser.test.tsx @@ -8,6 +8,7 @@ import { ThreadId, WS_METHODS, type IssueDetail, + type IssueRef, type ThreadIssueLink, } from "@t3tools/contracts"; import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings"; @@ -113,29 +114,33 @@ vi.mock(import("~/rpc/requestLatencyState"), async (original) => ({ trackRpcRequestSent: () => {}, })); -it("opens a linked issue from an inactive thread's sidebar badge", async () => { +it("opens a linked Linear issue from an inactive thread's sidebar badge", async () => { const style = document.createElement("style"); style.textContent = stylesheet; document.head.append(style); using _style = { [Symbol.dispose]: () => style.remove() }; const first = threadWithHistory("issue-first", 1); const linked = threadWithHistory("issue-linked", 1); - const issue: ThreadIssueLink = { + const issueRef = { projectId: PROJECT_ID, - tracker: IssueTrackerKind.make("github"), - host: "github.com", - scope: "example/project", - key: "123", - url: "https://github.com/example/project/issues/123", + tracker: IssueTrackerKind.make("linear"), + host: "linear.app", + scope: "WEB", + key: "WEB-123", + } satisfies IssueRef; + const issue: ThreadIssueLink = { + ...issueRef, + url: "https://linear.app/example/issue/WEB-123/add-keyboard-support", source: "manual", linkedAt: "2026-01-01T00:00:00.000Z", - displayKey: "#123", + displayKey: issueRef.key, title: "Add keyboard support", }; using _environment = installFakeEnvironment([first, { ...linked, issues: [issue] }]); const liveTitle = "Add keyboard shortcuts to the sidebar"; - using _detail = answerRpc(WS_METHODS.issuesDetail, () => - Effect.succeed({ + using _detail = answerRpc(WS_METHODS.issuesDetail, (input: IssueRef) => { + expect(input).toEqual(issueRef); + return Effect.succeed({ ...issue, title: liveTitle, author: { login: "sam", name: null, avatarUrl: null }, @@ -174,8 +179,8 @@ it("opens a linked issue from an inactive thread's sidebar badge", async () => { commentsCursor: null, events: [], linkedPullRequests: [], - } satisfies IssueDetail), - ); + } satisfies IssueDetail); + }); __setClientSettingsForTests({ ...DEFAULT_CLIENT_SETTINGS, onboardingCompletedAt: "2026-01-01T00:00:00.000Z", @@ -189,10 +194,14 @@ it("opens a linked issue from an inactive thread's sidebar badge", async () => { // AppRoot brings its own router. router: false, }); - const name = "Issue #123: Add keyboard support"; - const badge = page.getByRole("button", { name }); + const badge = page.getByRole("button", { + name: `Issue ${issue.displayKey}: ${issue.title}, Open`, + }); + await expect.element(badge).toBeVisible(); + expect(badge.element().querySelector("svg")).toHaveClass(/text-emerald-600/); await userEvent.hover(badge); - const previewLink = page.getByRole("link", { name: `Issue #123: ${liveTitle}` }); + const issueName = `Issue ${issue.displayKey}: ${liveTitle}`; + const previewLink = page.getByRole("link", { name: issueName }); await userEvent.hover(previewLink.getByText("sam", { exact: true })); await expect.element(previewLink).toBeVisible(); const contextMenu = new MouseEvent("contextmenu", { bubbles: true, cancelable: true }); @@ -201,13 +210,23 @@ it("opens a linked issue from an inactive thread's sidebar badge", async () => { await userEvent.click(badge); const issueRow = page .getByRole("region", { name: "Linked issues" }) - .getByRole("link", { name: `Issue #123: ${liveTitle}` }); + .getByRole("link", { name: issueName }); await expect.element(issueRow.getByRole("img", { name: "Open" })).toBeVisible(); await expect.element(issueRow.getByRole("img", { name: "3 comments" })).toBeVisible(); - await expect.element(issueRow.getByText("example/project")).toBeVisible(); + await expect.element(issueRow.getByRole("img", { name: "Linear" })).toBeVisible(); + await expect.element(issueRow.getByText(issue.scope, { exact: true })).toBeVisible(); await userEvent.click(issueRow); expect(router.history.location.pathname).toBe(`/${ENVIRONMENT_ID}/${linked.id}`); await expect.element(page.getByRole("heading", { name: liveTitle })).toBeVisible(); + await act(() => useRightPanelStore.getState().close(scopeThreadRef(ENVIRONMENT_ID, linked.id))); + await expect + .element( + page.getByRole("region", { name: "Thread details" }).getByRole("link", { + name: issueName, + exact: true, + }), + ) + .toBeVisible(); }); it("a machine chip stashed in one thread restores with its machine in another", async () => { diff --git a/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx b/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx index 772388057c91f..1308155dbf8ba 100644 --- a/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx +++ b/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx @@ -4,9 +4,7 @@ import type { MouseEvent } from "react"; import { cn } from "~/lib/utils"; import { useRightPanelStore } from "~/rightPanelStore"; -import { useServerConfigs } from "~/state/entities"; -import { issueEnvironment } from "~/state/issues"; -import { useEnvironmentQuery } from "~/state/query"; +import { useLinkedIssueDetail } from "~/state/issues"; import { IssueGlyph, @@ -20,6 +18,7 @@ import { } from "../pullRequest/PullRequestListRow"; import { PullRequestActorLabel } from "../pullRequest/pullRequestPresentation"; import { ThreadDetailsControl } from "./ThreadDetailsControl"; +import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; function LinkedIssueRow({ link, @@ -32,15 +31,8 @@ function LinkedIssueRow({ compact: boolean; onOpen: (() => void) | undefined; }) { - const { environmentId } = threadRef; - const configs = useServerConfigs(); - const { projectId, tracker, host, scope, key } = link; - const detail = useEnvironmentQuery( - configs.get(environmentId)?.environment.capabilities.issues === true - ? issueEnvironment.detail({ environmentId, input: { projectId, tracker, host, scope, key } }) - : null, - ).data; - const trackerPresentation = issueTrackerPresentation(tracker); + const detail = useLinkedIssueDetail(threadRef.environmentId, link); + const trackerPresentation = issueTrackerPresentation(link.tracker); const state = detail === null ? null : issueStatePresentation(detail.state); const Icon = state?.Icon ?? IssueGlyph.issue; const title = detail?.title ?? link.title; @@ -57,40 +49,46 @@ function LinkedIssueRow({ onOpen?.(); }, }; + const glyph = ( + + ); + const comments = + detail !== null && detail.commentCount > 0 ? ( + + + {detail.commentCount} + + ) : null; + const trackerIcon = ( + + ); const lines = ( <> - + {glyph} {link.displayKey}} title={title} - status={ - detail !== null && detail.commentCount > 0 ? ( - - - {detail.commentCount} - - ) : null - } + status={comments} meta={ <> {detail?.author ? ( ) : null} - - {scope} + {trackerIcon} + {link.scope} } updatedAt={detail?.updatedAt ?? link.linkedAt} @@ -98,9 +96,29 @@ function LinkedIssueRow({ ); return compact ? ( - }> - {lines} - +
+ + } />} + > + {glyph} + {title} + + +
{lines}
+
+
+
+ {link.displayKey} + {trackerIcon} + {comments} +
+
) : ( ({ select(AsyncResult.success(queryData()))) as never, useEnvironmentQueryIsNewer: () => true, useEnvironmentQueryRefresh: () => ({ refresh: vi.fn(), isPending: () => false }), - useEnvironmentQuery: ((atom: unknown) => ({ - data: - atom === null - ? null - : { - code: { additions: 1, deletions: 0 }, - tests: { additions: 0, deletions: 0 }, - mocks: { additions: 0, deletions: 0 }, - generated: { additions: 0, deletions: 0 }, - docs: { additions: 7, deletions: 3 }, - }, + useEnvironmentQuery: (() => ({ + data: { + code: { additions: 1, deletions: 0 }, + tests: { additions: 0, deletions: 0 }, + mocks: { additions: 0, deletions: 0 }, + generated: { additions: 0, deletions: 0 }, + docs: { additions: 7, deletions: 3 }, + }, isPending: false, })) as never, })); @@ -123,7 +119,6 @@ import { act, render as renderUi } from "../../../test/render"; import { useComposerDraftStore } from "~/composerDraftStore"; import { useUiStateStore } from "~/uiStateStore"; import { ThreadDetailsPrRow } from "./ThreadDetailsPrRow"; -import { ThreadDetailsIssueRows } from "./ThreadDetailsIssueRows"; import { ThreadDetailsThreadPrRows } from "./ThreadDetailsPrRows"; const threadRef: ScopedThreadRef = { @@ -365,36 +360,3 @@ it("names a linked pull request row by its kind, number and title, not its URL", expect(name).toContain("#1"); expect(name).toContain("Test PR"); }); - -it("names a linked issue row by its kind, number and title, not its URL", async () => { - await using screen = await setup(); - await act(async () => { - await screen.rerender( - , - ); - }); - const row = [...screen.container.querySelectorAll("a")].find((link) => - link.textContent?.includes("Sidebar flickers on resize"), - )!; - const name = row.getAttribute("aria-label") ?? row.textContent ?? ""; - expect(name).not.toContain("https://"); - expect(name).toMatch(/issue/i); - expect(name).toContain("#123"); - expect(name).toContain("Sidebar flickers on resize"); -}); diff --git a/apps/web/src/components/sidebar/SidebarThreadRow.tsx b/apps/web/src/components/sidebar/SidebarThreadRow.tsx index 28c51cd74e3dd..81bee7fb5b254 100644 --- a/apps/web/src/components/sidebar/SidebarThreadRow.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadRow.tsx @@ -75,6 +75,7 @@ import { useThreadSelectionStore } from "../../threadSelectionStore"; import { useNowMinute } from "../../hooks/useNowMinute"; import { useNowSecond } from "../../hooks/useNowSecond"; import { vcsEnvironment, vcsBranchRevalidation } from "../../state/vcs"; +import { useLinkedIssueDetail } from "../../state/issues"; import { useEnvironmentQuery } from "../../state/query"; import { readEnvironmentScope, useEnvironmentScope } from "../../state/session"; import { formatRelativeTimeLabel, parseTimestampDate } from "../../timestampFormat"; @@ -127,7 +128,7 @@ import { ActivityShimmerOverlay } from "../chat/TimelineRowParts"; import { observeVisibleAnimation } from "~/lib/visibleAnimation"; import { useThreadHasUnsentDraft } from "../../composerDraftStore"; import { ThreadDetailsIssueRows } from "../chat/ThreadDetailsIssueRows"; -import { IssueGlyph } from "../issue/issuePresentation"; +import { IssueGlyph, issueStatePresentation } from "../issue/issuePresentation"; // The fields thread rows show. Provider status pushes refresh `checkedAt`, // status and auth on every provider; leaving those out keeps each @@ -1110,9 +1111,16 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP ) : null; const firstIssue = thread.issues?.[0]; const issueCount = thread.issues?.length ?? 0; + const issueDetail = useLinkedIssueDetail( + thread.environmentId, + leaseLiveStatus && issueCount === 1 ? firstIssue : undefined, + "sidebar", + ); + const issueStatus = issueDetail === null ? null : issueStatePresentation(issueDetail.state); + const IssueIcon = issueStatus?.Icon ?? IssueGlyph.issue; const issueLabel = issueCount === 1 && firstIssue - ? `Issue ${firstIssue.displayKey}: ${firstIssue.title}` + ? `Issue ${firstIssue.displayKey}: ${firstIssue.title}${issueStatus ? `, ${issueStatus.label}` : ""}` : `${issueCount} linked issues`; const issueBadge = firstIssue ? ( @@ -1129,8 +1137,8 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP /> } > - - + + {issueCount === 1 ? firstIssue.displayKey : issueCount} diff --git a/apps/web/src/state/issues.ts b/apps/web/src/state/issues.ts index 8b9ae58df7d09..1bcdd796bc593 100644 --- a/apps/web/src/state/issues.ts +++ b/apps/web/src/state/issues.ts @@ -7,16 +7,37 @@ import { type MergedIssueList, } from "@t3tools/client-runtime/state/issues"; import { useAtomValue } from "@effect/atom-react"; -import type { EnvironmentId } from "@t3tools/contracts"; +import type { EnvironmentId, ThreadIssueLink } from "@t3tools/contracts"; import { connectionAtomRuntime } from "../connection/runtime"; import { appAtomRegistry } from "../rpc/atomRegistry"; -import { formatEnvironmentQueryError } from "./query"; +import { useServerConfigs } from "./entities"; +import { formatEnvironmentQueryError, useEnvironmentQuery } from "./query"; export type { IssueListTarget }; export const issueEnvironment = createIssueEnvironmentAtoms(connectionAtomRuntime); +export function useLinkedIssueDetail( + environmentId: EnvironmentId, + link: ThreadIssueLink | undefined, + mountScope?: "sidebar", +) { + const configs = useServerConfigs(); + const input = link && { + projectId: link.projectId, + tracker: link.tracker, + host: link.host, + scope: link.scope, + key: link.key, + }; + return useEnvironmentQuery( + input && configs.get(environmentId)?.environment.capabilities.issues === true + ? issueEnvironment.detail({ environmentId, input }, mountScope) + : null, + ).data; +} + const mergedIssueLists = createMergedIssueListAtoms( issueEnvironment.list, formatEnvironmentQueryError, diff --git a/packages/client-runtime/src/state/runtime.test.ts b/packages/client-runtime/src/state/runtime.test.ts index 97b5750872986..59093d2d9dbdc 100644 --- a/packages/client-runtime/src/state/runtime.test.ts +++ b/packages/client-runtime/src/state/runtime.test.ts @@ -1240,7 +1240,7 @@ describe("environment query lifecycle", () => { }), ); - it.effect("refetches when mounted again after its stale time, while still cached", () => + it.effect("refetches a stale query on remount while another view keeps the cache live", () => Effect.gen(function* () { let now = 0; using _now = vi.spyOn(Date, "now").mockImplementation(() => now); @@ -1254,6 +1254,11 @@ describe("environment query lifecycle", () => { ); const registry = AtomRegistry.make(); yield* Effect.addFinalizer(() => Effect.sync(() => registry.dispose())); + const sidebar = harness.family( + { environmentId: QUERY_ENVIRONMENT.environmentId, input: undefined }, + "sidebar", + ); + registry.mount(sidebar); const read = readEnvironmentQuery(registry, harness.atom); const remount = Effect.gen(function* () { const unmount = registry.mount(harness.atom); @@ -1275,6 +1280,7 @@ describe("environment query lifecycle", () => { // Past the stale time, well inside the default 5 minute idle TTL. now = 61_000; expect(yield* remount).toBe("after edit"); + expect(yield* readEnvironmentQuery(registry, sidebar)).toBe("after edit"); expect(fetches).toBe(2); }), ); diff --git a/packages/client-runtime/src/state/runtime.ts b/packages/client-runtime/src/state/runtime.ts index e61ac52f5e5b7..d20b0651eff05 100644 --- a/packages/client-runtime/src/state/runtime.ts +++ b/packages/client-runtime/src/state/runtime.ts @@ -711,15 +711,14 @@ export function createEnvironmentQueryAtomFamily( | AtomRegistry.AtomRegistry | R >, -): (target: { - readonly environmentId: EnvironmentIdType; - readonly input: Input; -}) => Atom.Atom> { +): ( + target: { readonly environmentId: EnvironmentIdType; readonly input: Input }, + mountScope?: string, +) => Atom.Atom> { const connectionAtom = environmentConnectionAtoms(runtime); // `Atom.family` holds members weakly and the mounted layer has no TTL, so each member lives // as long as its cache: keyed weakly, this lets both go once the cache's TTL ends. - const membersByCache = new WeakMap, Atom.Atom>(); - const family = Atom.family((key: string) => { + const cacheFamily = Atom.family((key: string) => { const target = parseEnvironmentRpcKey(key); const idleTtlMs = options.idleTtlMs ?? 5 * 60_000; const queryAtom = runtime @@ -853,19 +852,31 @@ export function createEnvironmentQueryAtomFamily( ? queryAtom : queryAtom.pipe(refreshEveryUntilFinal(options.refreshIntervalMs, isFinal)); const refreshTrigger = options.refreshTrigger?.(target); - const cache = ( + return ( refreshTrigger === undefined ? intervalQuery : intervalQuery.pipe(refreshOnSignalWhileRead(refreshTrigger, isFinal)) ).pipe(Atom.setIdleTTL(idleTtlMs)); + }); + type QueryAtom = ReturnType; + const membersByCache = new WeakMap>(); + return (target, mountScope) => { + const key = environmentRpcKey(target); + const cache = cacheFamily(key); + let members = membersByCache.get(cache); + if (members === undefined) { + members = new Map(); + membersByCache.set(cache, members); + } + const existing = members.get(mountScope); + if (existing !== undefined) return existing; const member = cache.pipe( revalidateOnMount(options.staleTimeMs ?? 30_000), - Atom.withLabel(`${options.label}:${key}`), + Atom.withLabel(`${options.label}:${key}${mountScope === undefined ? "" : `:${mountScope}`}`), ); - membersByCache.set(cache, member); + members.set(mountScope, member); return member; - }); - return (target) => family(environmentRpcKey(target)); + }; } export function createEnvironmentSubscriptionAtomFamily( From cbc456078e292f8a7f242eb7da6ee528c1ac52af Mon Sep 17 00:00:00 2001 From: maria-rcks Date: Wed, 18 Nov 2026 12:06:49 +0000 Subject: [PATCH 4/5] fix(web): preserve linked issue navigation and query refresh on current main --- .../chat/ThreadDetailsPrRow.browser.test.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx b/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx index 98cdd71258533..5fb1be8665fa7 100644 --- a/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx +++ b/apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx @@ -14,6 +14,7 @@ import { AsyncResult } from "effect/reactivity"; import { expect, it, vi } from "vite-plus/test"; const state = vi.hoisted(() => ({ + issuesSupported: false, isDraft: false, status: "success" as PullRequestCheck["status"], extraStatus: null as PullRequestCheck["status"] | null, @@ -40,13 +41,15 @@ vi.mock(import("~/state/entities"), async (importOriginal) => ({ new Map([ [ EnvironmentId.make("environment"), - { environment: { capabilities: { pullRequests: true } } }, + { environment: { capabilities: { pullRequests: true, issues: state.issuesSupported } } }, ], ])) as never, useProjects: (() => state.projects) as never, useQuietThreadShell: ((ref: unknown) => ref === null ? null : { branch: null, pullRequests: state.pullRequests }) as never, })); +vi.mock(import("~/state/issues"), () => ({ useLinkedIssueDetail: () => null })); + const queryData = () => ({ projectId: ProjectId.make("project"), workspaceRoot: "/workspace", @@ -255,6 +258,7 @@ async function setup() { state.addToast.mockReset().mockReturnValue("checkout-toast"); state.updateToast.mockReset(); + state.issuesSupported = false; state.isDraft = false; state.status = "success"; state.extraStatus = null; @@ -417,6 +421,11 @@ it("names a linked issue row by its kind, number and title, not its URL", async expect(name).toMatch(/issue/i); expect(name).toContain("#123"); expect(name).toContain("Sidebar flickers on resize"); + const externalClick = new MouseEvent("click", { bubbles: true, cancelable: true }); + await act(async () => { + row.dispatchEvent(externalClick); + }); + expect(externalClick.defaultPrevented).toBe(false); }); it("keeps Ready pending when refreshed detail becomes mergeable before the action settles", async () => { From 868750f0690e936cfc6a422a49c2932eaf62c18a Mon Sep 17 00:00:00 2001 From: maria-rcks Date: Wed, 18 Nov 2026 12:20:52 +0000 Subject: [PATCH 5/5] fix(web): refresh issue rows across independently opened views --- apps/web/src/components/chat/ThreadDetailsIssueRows.tsx | 7 ++++++- .../src/components/pullRequest/ThreadPullRequestsPanel.tsx | 7 ++++++- apps/web/src/components/sidebar/SidebarThreadRow.tsx | 1 + apps/web/src/state/issues.ts | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx b/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx index ca8d1e3794752..bb3a5e2d54d3d 100644 --- a/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx +++ b/apps/web/src/components/chat/ThreadDetailsIssueRows.tsx @@ -26,16 +26,18 @@ function LinkedIssueRow({ link, threadRef, compact, + mountScope, onOpen, }: { link: ThreadIssueLink; threadRef: ScopedThreadRef; compact: boolean; + mountScope: "thread-details" | "linked-items" | "sidebar-tooltip"; onOpen: (() => void) | undefined; }) { const gt = useGT(); const configs = useServerConfigs(); - const detail = useLinkedIssueDetail(threadRef.environmentId, link, "linked-items"); + const detail = useLinkedIssueDetail(threadRef.environmentId, link, mountScope); const trackerPresentation = issueTrackerPresentation(link.tracker); const state = detail === null ? null : issueStatePresentation(detail.state); const Icon = state?.Icon ?? IssueGlyph.issue; @@ -143,11 +145,13 @@ export function ThreadDetailsIssueRows({ links, threadRef, compact = true, + mountScope = "thread-details", onOpen, }: { links: ReadonlyArray; threadRef: ScopedThreadRef; compact?: boolean; + mountScope?: "thread-details" | "linked-items" | "sidebar-tooltip"; onOpen?: () => void; }) { return links.map((link) => ( @@ -156,6 +160,7 @@ export function ThreadDetailsIssueRows({ link={link} threadRef={threadRef} compact={compact} + mountScope={mountScope} onOpen={onOpen} /> )); diff --git a/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx b/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx index faacf830b2499..95185c23ae263 100644 --- a/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx +++ b/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx @@ -547,7 +547,12 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread

Issues

- +

{linkCount > 0 ? (

diff --git a/apps/web/src/components/sidebar/SidebarThreadRow.tsx b/apps/web/src/components/sidebar/SidebarThreadRow.tsx index ffa94b4acddfb..f3505bd2c66bf 100644 --- a/apps/web/src/components/sidebar/SidebarThreadRow.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadRow.tsx @@ -1185,6 +1185,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP links={thread.issues ?? []} threadRef={threadRef} compact={false} + mountScope="sidebar-tooltip" onOpen={() => { if (!props.isRouteThread) onThreadActivate(threadRef); }} diff --git a/apps/web/src/state/issues.ts b/apps/web/src/state/issues.ts index 02d1d737629d6..16679aa25f1c7 100644 --- a/apps/web/src/state/issues.ts +++ b/apps/web/src/state/issues.ts @@ -21,7 +21,7 @@ export const issueEnvironment = createIssueEnvironmentAtoms(connectionAtomRuntim export function useLinkedIssueDetail( environmentId: EnvironmentId, link: ThreadIssueLink | undefined, - mountScope?: "sidebar" | "linked-items", + mountScope?: "sidebar" | "thread-details" | "linked-items" | "sidebar-tooltip", ) { const configs = useServerConfigs(); const input = link && {