@@ -117,17 +122,59 @@ function CardDraftContent({
const session = cardThreadSession(item, board?.phases, currentItemStage(item, board) ?? '');
if (session) return
;
+ const panel: WorkspacePanelPage = {
+ subject: lead =>
,
+ overview: () => (
+
+ ),
+ };
+
return (
-
}
- >
- {guards.missingModel || guards.missingCredential ? (
-
- ) : (
-
- )}
-
+
+ }
+ headerActions={}
+ dockActions={actions => {actions}}
+ >
+ {guards.missingModel || guards.missingCredential ? (
+
+ ) : (
+
+ )}
+
+
+ );
+}
+
+function CardDraftOverview({
+ factory,
+ item,
+ boards,
+ boardsFailed,
+}: {
+ factory: FactoryProject;
+ item: WorkItem;
+ boards: readonly InstalledBoardInfo[] | undefined;
+ boardsFailed: boolean;
+}) {
+ const lookup = useCardSessionRepository(factory.id, item);
+ if (lookup.isPending) return
;
+
+ const resolved = lookup.data?.status === 'resolved' ? lookup.data : undefined;
+ const repository =
+ resolved && factory.repositories.find(linked => linked.projectRepositoryId === resolved.projectRepositoryId);
+ return (
+
);
}
diff --git a/mastracode/factory-ui/src/ui/pages/ThreadPage.tsx b/mastracode/factory-ui/src/ui/pages/ThreadPage.tsx
index 09c3064a4be..4f7c560127e 100644
--- a/mastracode/factory-ui/src/ui/pages/ThreadPage.tsx
+++ b/mastracode/factory-ui/src/ui/pages/ThreadPage.tsx
@@ -57,7 +57,7 @@ export function ThreadPage() {
return (
-
+
diff --git a/mastracode/factory-ui/src/ui/pages/__tests__/CardDraftPage.msw.test.tsx b/mastracode/factory-ui/src/ui/pages/__tests__/CardDraftPage.msw.test.tsx
index 217eeb7882a..c46ac1259fb 100644
--- a/mastracode/factory-ui/src/ui/pages/__tests__/CardDraftPage.msw.test.tsx
+++ b/mastracode/factory-ui/src/ui/pages/__tests__/CardDraftPage.msw.test.tsx
@@ -2,7 +2,7 @@ import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { http, HttpResponse } from 'msw';
import { createMemoryRouter, RouterProvider } from 'react-router';
-import { describe, expect, it } from 'vitest';
+import { afterEach, describe, expect, it, vi } from 'vitest';
import { server } from '../../../../e2e/ui/msw-server';
import { renderWithProviders, TEST_BASE_URL, waitForMutationsIdle } from '../../../../e2e/ui/render';
@@ -34,6 +34,22 @@ const linearCard = {
},
};
+const PULL_REQUEST_NUMBER = 30647;
+const PULL_REQUEST_URL = `https://github.com/acme/app/pull/${PULL_REQUEST_NUMBER}`;
+const PULL_REQUEST_BODY = 'Stops the unhandled rejection when a stream aborts.';
+const pullRequestCard = {
+ ...linearCard,
+ title: 'fix(core): stop the unhandled rejection',
+ externalSource: {
+ integrationId: 'github',
+ type: 'pull-request',
+ externalId: String(PULL_REQUEST_NUMBER),
+ url: PULL_REQUEST_URL,
+ },
+ metadata: { githubPullRequestNumber: PULL_REQUEST_NUMBER, number: PULL_REQUEST_NUMBER, state: 'open' },
+ workItem: null,
+};
+
function stubCard(metadata: Record
= linearCard.metadata) {
const runStarts: unknown[] = [];
server.use(
@@ -63,13 +79,20 @@ function renderAt(path: string) {
return { router, ...renderWithProviders(, createQueryClient()) };
}
+function stubPageWidth(width: number) {
+ vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(() => new DOMRect(0, 0, width, 800));
+}
+
describe('a card without a session', () => {
+ afterEach(() => vi.restoreAllMocks());
+
it('opens on a draft titled after the card that creates nothing until the first prompt', async () => {
const route = stubDraftRoute();
const runStarts = stubCard();
const { router } = renderAt(`/factories/${FACTORY_ID}/cards/${CARD_ID}`);
expect(await screen.findByRole('heading', { level: 2, name: linearCard.title })).toBeInTheDocument();
+ expect(screen.queryByRole('heading', { level: 1, name: 'New session' })).not.toBeInTheDocument();
expect(router.state.location.pathname).toMatch(
new RegExp(`^/factories/${FACTORY_ID}/cards/${CARD_ID}/new/[0-9a-f-]{36}$`),
);
@@ -78,6 +101,31 @@ describe('a card without a session', () => {
expect(runStarts).toEqual([]);
});
+ it("shows the card's pull request and description in the session panel before any session exists", async () => {
+ stubPageWidth(1200);
+ const route = stubDraftRoute();
+ stubCard();
+ server.use(
+ http.get(`${TEST_BASE_URL}/web/factory/projects/${FACTORY_ID}/work-items`, () =>
+ HttpResponse.json({ workItems: [pullRequestCard] }),
+ ),
+ http.get(`${TEST_BASE_URL}/web/github/projects/:repository/prs/:number`, ({ params }) =>
+ HttpResponse.json({ number: Number(params.number), description: PULL_REQUEST_BODY }),
+ ),
+ );
+ renderAt(`/factories/${FACTORY_ID}/cards/${CARD_ID}/new/${DRAFT_SESSION_ID}`);
+
+ const panel = await screen.findByRole('complementary', { name: 'Session panel' });
+ const card = await within(panel).findByRole('region', { name: 'Card' });
+ expect(await within(card).findByRole('link', { name: `Open PR #${PULL_REQUEST_NUMBER}` })).toHaveAttribute(
+ 'href',
+ PULL_REQUEST_URL,
+ );
+ expect(await within(card).findByText(PULL_REQUEST_BODY)).toBeInTheDocument();
+ expect(within(panel).queryByRole('region', { name: 'Workspace' })).not.toBeInTheDocument();
+ expect(route.createBodies).toEqual([]);
+ });
+
it("offers the card's next step on the draft and moves the card into it", async () => {
stubDraftRoute();
const runStarts = stubCard();
From 4deef12c52d11727605239603882fbb563496b3b Mon Sep 17 00:00:00 2001
From: Damien Schneider <74979845+damien-schneider@users.noreply.github.com>
Date: Mon, 16 Nov 2026 21:30:14 -0800
Subject: [PATCH 2/2] chore: add changeset for the card draft session panel
---
.changeset/factory-card-draft-panel.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 .changeset/factory-card-draft-panel.md
diff --git a/.changeset/factory-card-draft-panel.md b/.changeset/factory-card-draft-panel.md
new file mode 100644
index 00000000000..e881d184b80
--- /dev/null
+++ b/.changeset/factory-card-draft-panel.md
@@ -0,0 +1,5 @@
+---
+'mastra': patch
+---
+
+Opening a Factory card that has no session yet now shows the session panel, as the card's sessions do. Before you send the first message, it lists the card's source, its pull request, its description, the pull requests it links to and the stages it has moved through. The page also drops its **New session** title, matching a card's session page.