@@ -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();