An open-source, faster Devin alternative
TypeScript
Session view: link the work items the session's commits name
Igor Zalutski via Computer969e378d8e8d
diff --git a/web/src/managed-agents/computer-sessions/Session.tsx b/web/src/managed-agents/computer-sessions/Session.tsxindex 2d948979..3a540bb9 100644--- a/web/src/managed-agents/computer-sessions/Session.tsx+++ b/web/src/managed-agents/computer-sessions/Session.tsx@@ -21,6 +21,7 @@ import {} from '../computer-sessions-api'import { Item } from './conversation'import { useMemberEmails } from './members'+import { SessionWork } from '../work/SessionWork'import { AskCard, SettingsPickers, StatusDot } from './parts'import {isBusy,@@ -215,6 +216,7 @@ function Header({ id }: { id: string }) {· {s.owner.name}</span>) : null}+ <SessionWork id={id} /></div>{slackUrl ? (<Button asChild size="sm" variant="ghost">diff --git a/web/src/managed-agents/work/SessionWork.tsx b/web/src/managed-agents/work/SessionWork.tsxnew file mode 100644index 00000000..1c6afe77--- /dev/null+++ b/web/src/managed-agents/work/SessionWork.tsx@@ -0,0 +1,51 @@+import { Link } from 'react-router-dom'+import { useQuery } from '@tanstack/react-query'+import { getSessionItems, useOrg, workKeys } from './api'++// How many items the session header names; the rest are a count.+const SHOWN = 2++/**+ * The tracked items a session worked on (its commits' `Session:` trailers),+ * as quiet chips in the session's header, each linking to the item. Nothing+ * while loading, on any error (no repository, Work unavailable) or when the+ * session named no item.+ */+export function SessionWork({ id }: { id: string }) {+ const org = useOrg()+ const { data: items } = useQuery({+ queryKey: workKeys.session(org, id),+ queryFn: () => getSessionItems(id),+ retry: false,+ staleTime: 60_000,+ })+ if (!items?.length) return null+ const more = items.length - SHOWN+ return (+ <span className="flex min-w-0 shrink items-center gap-1.5">+ {items.slice(0, SHOWN).map((item) => (+ <Link+ key={item.number}+ to={`/computer/work/${item.number}`}+ title={`Work item ${item.number}: ${item.title}`}+ className="text-muted-foreground hover:text-foreground hover:border-foreground/25 inline-flex h-5 max-w-56 min-w-0 items-center gap-1 rounded-sm border px-1.5 text-xs transition-colors"+ >+ <span className="shrink-0">Work:</span>+ <span className="shrink-0 tabular-nums">{item.number}</span>+ <span className="truncate">{item.title}</span>+ </Link>+ ))}+ {more > 0 ? (+ <span+ className="text-muted-foreground shrink-0 text-xs"+ title={items+ .slice(SHOWN)+ .map((i) => `${i.number} ${i.title}`)+ .join('\n')}+ >+ +{more}+ </span>+ ) : null}+ </span>+ )+}diff --git a/web/src/managed-agents/work/screens.test.tsx b/web/src/managed-agents/work/screens.test.tsxindex 8095707a..3223252f 100644--- a/web/src/managed-agents/work/screens.test.tsx+++ b/web/src/managed-agents/work/screens.test.tsx@@ -17,6 +17,7 @@ const workApi = vi.hoisted(() => ({getRepository: vi.fn(),putRepository: vi.fn(),getRepositories: vi.fn(),+ getSessionItems: vi.fn(),}))vi.mock('./api', async (importOriginal) => ({...(await importOriginal<typeof import('./api')>()),@@ -26,6 +27,7 @@ vi.mock('./api', async (importOriginal) => ({const { Board } = await import('./Board')const { ItemView } = await import('./Item')const { KnowledgeRepositorySection } = await import('./KnowledgeRepository')+const { SessionWork } = await import('./SessionWork')const repository = {installationId: '1',@@ -95,6 +97,10 @@ async function render(url: string) {path="/computer"element={<KnowledgeRepositorySection id="work-repository" />}/>+ <Route+ path="/computer/sessions/cs_7"+ element={<SessionWork id="cs_7" />}+ /></Routes></MemoryRouter></QueryClientProvider>@@ -569,6 +575,37 @@ describe('item page', () => {})})+describe('session header', () => {+ it('links the items the session worked on, two by name and a count', async () => {+ workApi.getSessionItems.mockResolvedValue([+ makeItem({ number: 114, title: 'Work tracking' }),+ makeItem({ number: 7, title: 'Billing' }),+ makeItem({ number: 9, title: 'Docs' }),+ ])+ await render('/computer/sessions/cs_7')+ expect(workApi.getSessionItems).toHaveBeenCalledWith('cs_7')+ const links = [...document.body.querySelectorAll('a')]+ expect(links.map((a) => a.getAttribute('href'))).toEqual([+ '/computer/work/114',+ '/computer/work/7',+ ])+ expect(links[0].textContent).toBe('Work:114Work tracking')+ expect(links[0].getAttribute('title')).toBe('Work item 114: Work tracking')+ expect(document.body.textContent).toContain('+1')+ })++ it('shows nothing when the session named no item or Work cannot answer', async () => {+ workApi.getSessionItems.mockResolvedValue([])+ await render('/computer/sessions/cs_7')+ expect(document.body.querySelector('a')).toBeNull()+ workApi.getSessionItems.mockRejectedValue(+ new ApiError('Work is unavailable.', 503, 'unavailable'),+ )+ await render('/computer/sessions/cs_7')+ expect(document.body.querySelector('a')).toBeNull()+ })+})+const granted = (name: string,pushedAt: string | null,