Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions apps/web/src/components/BranchToolbarBranchSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -913,20 +913,7 @@ export function BranchToolbarBranchSelector({
/>
) : null}
{displayMode === "panel" ? (
<ThreadDetailsIssueRows
links={linkedIssues}
onOpenLink={(event, link) => {
event.stopPropagation();
useRightPanelStore.getState().openIssue(threadRef, {
projectId: link.projectId,
tracker: link.tracker,
host: link.host,
scope: link.scope,
key: link.key,
url: link.url,
});
}}
/>
<ThreadDetailsIssueRows links={linkedIssues} threadRef={threadRef} />
) : null}
</div>
</BranchPicker>
Expand Down
120 changes: 120 additions & 0 deletions apps/web/src/components/ChatView.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ 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 IssueRef,
type ThreadIssueLink,
} from "@t3tools/contracts";
import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings";
import {
Expand All @@ -24,6 +28,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";
Expand Down Expand Up @@ -109,6 +114,121 @@ vi.mock(import("~/rpc/requestLatencyState"), async (original) => ({
trackRpcRequestSent: () => {},
}));

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 issueRef = {
projectId: PROJECT_ID,
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: 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, (input: IssueRef) => {
expect(input).toEqual(issueRef);
return Effect.succeed({
...issue,
title: liveTitle,
author: { login: "sam", name: null, avatarUrl: null },
state: { category: "open", name: "Open" },
createdAt: issue.linkedAt,
updatedAt: issue.linkedAt,
closedAt: null,
assignees: [],
labels: [],
commentCount: 3,
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 router={router} />, {
// AppRoot brings its own router.
router: false,
});
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 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 });
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: issueName });
await expect.element(issueRow.getByRole("img", { name: "Open" })).toBeVisible();
await expect.element(issueRow.getByRole("img", { name: "3 comments" })).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 () => {
const other = threadWithHistory("thread-stash-restore", 1);
const asking = threadWithQuestion("thread-stash-question", "Which file should change?");
Expand Down
7 changes: 5 additions & 2 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2014,6 +2014,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,
);
Expand Down Expand Up @@ -2441,7 +2444,7 @@ export default function ChatView(props: ChatViewProps) {
canMaximizeRightPanel,
rightPanelMaximized,
supportsPullRequests,
pullRequestsSurfaceAvailable,
pullRequestsSurfaceAvailable: linkedItemsSurfaceAvailable,
gitCwd,
activeProjectCwd,
onDiffPanelOpen,
Expand Down Expand Up @@ -4083,7 +4086,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}
Expand Down
8 changes: 5 additions & 3 deletions apps/web/src/components/CommandPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1508,9 +1508,11 @@ function OpenCommandPaletteDialog(props: {
actionItems.push({
kind: "action",
value: "action:open-thread-pull-requests",
searchTerms: ["pull requests", "linked", "stack", "prs"],
title: gt("Show linked pull requests"),
disabled: visibleThreadPullRequests(activeThread.pullRequests).length === 0,
searchTerms: ["pull requests", "issues", "linked", "stack", "prs"],
title: gt("Show linked items"),
disabled:
visibleThreadPullRequests(activeThread.pullRequests).length === 0 &&
!activeThread.issues?.length,
icon: <PullRequestGlyph.link className={ITEM_ICON_CLASS} />,
run: async () => {
useRightPanelStore.getState().open(threadRef, "pull-requests");
Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/components/RightPanelTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const SURFACE_DISABLED_REASONS = {
files: msg("Files are only available when a project is open."),
diff: msg("Diff is only available for server threads in Git repositories."),
pullRequest: msg("This thread's branch has no pull request yet."),
pullRequests: msg("No linked pull requests are available for this thread."),
pullRequests: msg("This thread has no linked items."),
device: msg("Devices are only available from a thread."),
sideChat: msg("Side chats start after the first message."),
} as const;
Expand All @@ -210,7 +210,7 @@ const SURFACE_UNAVAILABLE_HINTS = {
files: msg("Available when a project is open."),
diff: msg("Available for Git repositories."),
pullRequest: msg("No pull request on this branch yet."),
pullRequests: msg("No linked pull requests available."),
pullRequests: msg("No linked items available."),
device: msg("Available from a thread."),
sideChat: msg("Available after the first message."),
} as const;
Expand Down Expand Up @@ -391,7 +391,7 @@ function RightPanelEmptyState(props: {
onClick: props.onAddPullRequest,
},
{
label: msg("Linked pull requests"),
label: msg("Linked items"),
icon: PullRequestGlyph.link,
shortcut: "L",
available: props.pullRequestsAvailable,
Expand Down Expand Up @@ -606,7 +606,7 @@ function surfaceTitle(
case "pull-request":
return `#${surface.number}`;
case "pull-requests":
return resolve(msg("Pull requests"));
return resolve(msg("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;
Expand Down Expand Up @@ -1210,7 +1210,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
onClick: props.onAddPullRequest,
},
{
label: msg("Linked pull requests"),
label: msg("Linked items"),
icon: PullRequestGlyph.link,
shortcut: "L",
available: props.pullRequestsAvailable,
Expand Down
Loading
Loading