An open-source, faster Devin alternative
TypeScript
Board: fold dormant items, show the owner and link the item's sessions
Igor Zalutski via Computer3a0aceb713cc
diff --git a/web/src/api/mock-work.ts b/web/src/api/mock-work.tsindex 03fdde01..9b19586e 100644--- a/web/src/api/mock-work.ts+++ b/web/src/api/mock-work.ts@@ -21,6 +21,12 @@ const maya = { email: '[email protected]', name: 'Maya Chen', id: 'usr_maya' }const sam = { email: '[email protected]', name: 'Sam Okafor', id: 'usr_sam' }const priya = { email: '[email protected]', name: 'Priya Raman', id: null }+// An owner the doc declares (`owner:`), or one derived from the author of the+// doc's latest change that was not a bulk edit.+type Who = { email: string; name: string | null; id: string | null }+const declared = (p: Who) => ({ ...p, source: 'declared' })+const derived = (p: Who) => ({ ...p, source: 'derived' })+// The first seeded sessions in mock-computer-sessions.ts, so links open.const S1 = 'cs_000000000001'const S2 = 'cs_000000000002'@@ -96,14 +102,17 @@ const pr = (n: number, state: string | null, title: string) => ({function item(number: number,title: string,- over: Partial<Json> & { updated: number },+ // `activity`: minutes since the latest change that was not a bulk edit+ // (default `updated`; null for none read).+ over: Partial<Json> & { updated: number; activity?: number | null },): Json {const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')const path = `work/${String(number).padStart(3, '0')}-${slug}.md`- const { updated, ...rest } = over+ const { updated, activity = updated, ...rest } = over+ const attention = (over.attention as Json | null | undefined) ?? nullreturn {number,stage: 'open',@@ -123,6 +132,10 @@ function item(sessions: [],unpublished: false,updatedAt: ago(updated),+ lastActivityAt: activity === null ? null : ago(activity),+ // The server's rule: changed in the last 14 days, or a session is+ // working or waiting.+ active: (activity !== null && activity < 14 * D) || attention !== null,createdAt: ago(updated + 5 * D),closedAt: null,closedBy: null,@@ -136,7 +149,7 @@ const open: Json[] = [stateLine:'Metering ships behind the invoice preview; the price table needs a decision.',tags: ['billing', 'pricing', 'invoices'],- owner: igor,+ owner: declared(igor),mine: true,left: 3,warnings: ['The "Left" section has an item with no checkbox.'],@@ -166,7 +179,7 @@ const open: Json[] = [updated: 3 * H,stateLine: 'Database done; the queue and object store keys are left.',tags: ['security', 'infra'],- owner: igor,+ owner: derived(igor),mine: true,left: 2,attention: { state: 'waiting_on', name: 'Maya', since: ago(3 * H) },@@ -184,7 +197,7 @@ const open: Json[] = [stateLine:'Comparing three libraries on bundle size, dark theme and how they draw a gap in the data; Recharts leads, but its tooltips need work before it can ship.',tags: ['frontend'],- owner: igor,+ owner: derived(igor),mine: true,left: 4,attention: { state: 'working', name: null, since: ago(15) },@@ -201,7 +214,7 @@ const open: Json[] = [updated: 20 * D,stateLine: 'Half the pages are moved; search is not wired up.',tags: ['docs'],- owner: igor,+ owner: declared(igor),mine: true,left: 5,pullRequests: [pr(3920, 'closed', 'Docs theme, first pass')],@@ -210,7 +223,7 @@ const open: Json[] = [updated: 2 * H,stateLine: 'Reproduced with nested lists; the fix is in review.',tags: ['slack', 'bug'],- owner: maya,+ owner: derived(maya),left: 1,pullRequests: [pr(4201, 'open', 'Keep nested lists in Slack replies')],attention: { state: 'needs_you', name: null, since: ago(50) },@@ -230,7 +243,7 @@ const open: Json[] = [updated: 6 * H,stateLine: 'Snapshot restore is 40% faster in staging; measuring prod.',tags: ['infra', 'performance', 'sandboxes', 'workers'],- owner: sam,+ owner: declared(sam),left: 2,attention: { state: 'waiting_on', name: 'Sam', since: ago(6 * H) },warnings: ['The "Left" section has an item with no checkbox.'],@@ -240,24 +253,35 @@ const open: Json[] = [updated: D + 4 * H,stateLine: null,tags: ['onboarding'],- owner: null,+ owner: derived(priya),author: priya,left: 6,}),- // The index has not read its last commit yet: no time on the card.+ // The index has not read its commits yet: no time and no owner on the+ // card, but a session is working on it, so it is active.item(31, 'Look into the flaky end-to-end test', {updated: 2 * D,+ activity: null,updatedAt: null,stateLine: null,owner: null,- author: sam,+ author: null,left: 1,+ attention: { state: 'working', name: null, since: ago(4) },+ sessions: [+ {+ id: S3,+ title: 'Bisect the flaky test',+ ownerName: 'Sam Okafor',+ status: 'running',+ },+ ],}),item(29, 'Audit log export', {updated: 3 * D,stateLine: 'The CSV shape is agreed; the API route is next.',tags: ['security'],- owner: priya,+ owner: declared(priya),author: priya,left: 2,pullRequests: [pr(4150, null, 'Audit log export')],@@ -266,7 +290,7 @@ const open: Json[] = [updated: 5 * H,stateLine: 'Shipped in #4170; nothing left in the doc.',tags: ['api'],- owner: igor,+ owner: derived(igor),mine: true,left: 0,readyToClose: true,@@ -277,11 +301,72 @@ const open: Json[] = [updated: D + 2 * H,stateLine: 'Merged and released in 0.31.',tags: ['cli'],- owner: sam,+ owner: derived(sam),left: 0,readyToClose: true,pullRequests: [pr(4160, 'merged', 'Rename projects to apps')],}),+ // Dormant: no change of its own in 14 days and no session at work.+ item(5, 'Retire the v1 webhooks endpoint', {+ // A bulk edit touched it yesterday; its own last change is older.+ updated: D,+ activity: 41 * D,+ stateLine: 'Two customers still call v1; both have been told.',+ tags: ['api'],+ owner: derived(sam),+ left: 2,+ }),+ item(6, 'Single sign-on with Okta', {+ updated: 33 * D,+ stateLine: 'SAML works against a test tenant; SCIM is not started.',+ tags: ['security', 'enterprise'],+ owner: declared(maya),+ left: 4,+ pullRequests: [pr(3990, 'draft', 'SAML login')],+ }),+ item(11, 'Per-team usage caps', {+ updated: 26 * D,+ stateLine: 'Waiting for usage-based billing to land.',+ tags: ['billing'],+ owner: derived(igor),+ mine: true,+ left: 3,+ sessions: [+ {+ id: S2,+ title: 'Sketch team caps',+ ownerName: 'Igor',+ status: 'idle',+ },+ ],+ }),+ item(7, 'Document the rate limits', {+ updated: 52 * D,+ stateLine: null,+ tags: ['docs', 'api'],+ owner: derived(priya),+ left: 1,+ }),+ // No commit of its own in the index's reach: no derived owner.+ item(3, 'Dark mode for the status page', {+ updated: 70 * D,+ activity: null,+ stateLine: null,+ tags: ['frontend'],+ owner: null,+ author: null,+ left: 2,+ }),+ item(10, 'Remove the beta banner', {+ updated: 18 * D,+ stateLine: 'Removed everywhere; nothing left in the doc.',+ tags: ['frontend'],+ owner: derived(igor),+ mine: true,+ left: 0,+ readyToClose: true,+ pullRequests: [pr(3980, 'merged', 'Drop the beta banner')],+ }),]const closed: Json[] = [@@ -290,7 +375,7 @@ const closed: Json[] = [stage: 'closed',stateLine: 'A cold Durable Object; fixed by warming it on deploy.',tags: ['infra', 'bug'],- owner: igor,+ owner: declared(igor),mine: true,left: 0,pullRequests: [pr(4171, 'merged', 'Warm the edge object on deploy')],@@ -302,7 +387,7 @@ const closed: Json[] = [stage: 'closed',stateLine: 'Published on the blog.',tags: ['marketing'],- owner: maya,+ owner: derived(maya),left: 0,closedAt: ago(4 * D),closedBy: 'Maya Chen',@@ -312,7 +397,7 @@ const closed: Json[] = [stage: 'closed',stateLine: 'All routes load and tests pass.',tags: ['frontend'],- owner: igor,+ owner: derived(igor),mine: true,left: 0,pullRequests: [pr(4100, 'merged', 'React Router 7')],@@ -324,7 +409,7 @@ const closed: Json[] = [stage: 'closed',stateLine: null,tags: ['billing'],- owner: sam,+ owner: declared(sam),left: 0,// Closed, but when and by whom is not known yet: just "Closed".closedAt: null,@@ -332,10 +417,16 @@ const closed: Json[] = [}),]+// Only a declared owner is in the doc.+const ownerLine = (it: Json) => {+ const o = it.owner as { email: string; source: string } | null+ return o?.source === 'declared' ? o.email : ''+}+const body = (it: Json) => `---number: ${String(it.number)}title: ${String(it.title)}-owner: ${(it.owner as { email: string } | null)?.email ?? ''}+owner: ${ownerLine(it)}tags: [${(it.tags as string[]).join(', ')}]---@@ -480,6 +571,16 @@ export function workMock(items: visible(open),}}+ const linked = rest.match(/^\/sessions\/([^/]+)\/items$/)+ if (linked && method === 'GET') {+ const id = decodeURIComponent(linked[1])+ const all = current ? [...open, ...closed] : []+ return {+ items: all.filter((i) =>+ (i.sessions as { id: string }[]).some((x) => x.id === id),+ ),+ }+ }const m = rest.match(/^\/items\/(\d+)(\/history)?$/)if (m) {const it = [...open, ...closed].find((i) => i.number === Number(m[1]))diff --git a/web/src/managed-agents/work/Board.tsx b/web/src/managed-agents/work/Board.tsxindex 7b220249..ce74d8ae 100644--- a/web/src/managed-agents/work/Board.tsx+++ b/web/src/managed-agents/work/Board.tsx@@ -2,9 +2,9 @@ import { useContext, type ReactNode } from 'react'import { Link, Navigate, useSearchParams } from 'react-router-dom'import { useInfiniteQuery } from '@tanstack/react-query'import {+ ChevronRight,FileText,Loader2,- MessagesSquare,Search,SquareKanban,X,@@ -22,18 +22,18 @@ import {indexIsOld,inProgress,matches,- plural,readyToClose,repositoryName,repositoryProblem,- staleDays,+ splitDormant,type Filters,type Tab,} from './board'import {AttentionMark,- Avatar,+ OwnerMark,PullDots,+ SessionDots,Tag,UnpublishedMark,WarningMark,@@ -61,6 +61,15 @@ export function Board() {tag: params.get('tag'),}const showOlder = params.get('older') === '1'+ // Which lanes show their dormant cards: `dormant=progress,ready`.+ const unfolded = new Set((params.get('dormant') ?? '').split(','))+ const toggleDormant = (lane: Lane) => {+ const next = new Set(unfolded)+ if (next.has(lane)) next.delete(lane)+ else next.add(lane)+ next.delete('')+ setParam('dormant', [...next].sort().join(',') || null)+ }const setParam = (k: string, v: string | null) =>setParams((p) => {@@ -132,10 +141,10 @@ export function Board() {const closedItems = closed.data?.pages.flatMap((p) => p.items) ?? []const all = [...page.items, ...closedItems]const shown = all.filter((i) => matches(i, filters))- const progress = inProgress(shown)- const ready = readyToClose(shown)+ const progress = splitDormant(inProgress(shown))+ const ready = splitDormant(readyToClose(shown))const done = closedShown(shown, showOlder)- const needYou = progress.filter(+ const needYou = progress.active.filter((i) => i.attention?.state === 'needs_you',).lengthconst filtering = !!filters.q.trim() || !!filters.tag@@ -196,23 +205,41 @@ export function Board() {<div className="grid gap-4 lg:grid-cols-3"><Columntitle="In progress"- count={progress.length}+ count={progress.active.length}note={needYou ? `${needYou} need${needYou === 1 ? 's' : ''} you` : null}accent={needYou > 0}empty={page.building ? 'Reading the working docs…' : undefined}+ dormant={+ <Dormant+ lane="progress"+ items={progress.dormant}+ open={unfolded.has('progress')}+ onToggle={toggleDormant}+ onTag={(t) => setParam('tag', t)}+ />+ }>- {progress.map((i) => (+ {progress.active.map((i) => (<Card key={i.number} item={i} onTag={(t) => setParam('tag', t)} />))}</Column><Columntitle="Ready to close"- count={ready.length}+ count={ready.active.length}note="nothing left in the doc"+ dormant={+ <Dormant+ lane="ready"+ items={ready.dormant}+ open={unfolded.has('ready')}+ onToggle={toggleDormant}+ onTag={(t) => setParam('tag', t)}+ />+ }>- {ready.map((i) => (+ {ready.active.map((i) => (<Card key={i.number} item={i} onTag={(t) => setParam('tag', t)}>{/* Close arrives in build step 5. */}</Card>@@ -255,6 +282,58 @@ export function Board() {)}+type Lane = 'progress' | 'ready'++/**+ * A lane's dormant cards, folded under a quiet "Dormant (N)" until asked+ * for. Nothing when the lane has none.+ */+function Dormant({+ lane,+ items,+ open,+ onToggle,+ onTag,+}: {+ lane: Lane+ items: Item[]+ open: boolean+ onToggle: (lane: Lane) => void+ onTag: (tag: string) => void+}) {+ if (!items.length) return null+ const id = `work-dormant-${lane}`+ return (+ <div>+ <button+ type="button"+ aria-expanded={open}+ aria-controls={id}+ title="No change of their own in two weeks and no session at work"+ onClick={() => onToggle(lane)}+ className="text-muted-foreground hover:text-foreground flex h-8 w-full items-center gap-1 rounded-md px-[13px] text-xs transition-colors"+ >+ <ChevronRight+ className={cn(+ '-ml-1 size-3.5 transition-transform',+ open && 'rotate-90',+ )}+ aria-hidden+ />+ Dormant+ <span className="tabular-nums">({items.length})</span>+ </button>+ {open ? (+ <div id={id} className="flex flex-col gap-2">+ {items.map((i) => (+ <Card key={i.number} item={i} onTag={onTag} />+ ))}+ </div>+ ) : null}+ </div>+ )+}+function WhatIsAnItem() {return (<>@@ -404,6 +483,7 @@ function Column({note,accent,empty = 'None',+ dormant,footer,children,}: {@@ -414,6 +494,8 @@ function Column({accent?: boolean// What an empty lane says.empty?: string+ // The lane's folded dormant cards, below its active ones.+ dormant?: ReactNodefooter?: ReactNodechildren: ReactNode}) {@@ -442,6 +524,9 @@ function Column({{count === 0 ? (<p className="text-muted-foreground px-[13px] py-2 text-xs">{empty}</p>) : null}+ {dormant ? (+ <div className={cn(count > 0 && 'mt-2')}>{dormant}</div>+ ) : null}{footer ? <div className="px-[13px] pt-3 pb-1">{footer}</div> : null}</section>)@@ -462,18 +547,20 @@ export function Card({// The card's action (Close, Reopen), from build step 5.children?: ReactNode}) {- const stale = staleDays(item)const closed = item.stage === 'closed'+ const dormant = !closed && !item.activeconst shownTags = item.tags.slice(0, MAX_TAGS)const moreTags = item.tags.slice(MAX_TAGS)- const sessions = item.sessions.length- // When it last changed, or closed; unknown yet shows nothing.- const when = closed ? (item.closedAt ?? item.updatedAt) : item.updatedAt+ // When it closed, or last changed (its own change, not a bulk edit, when+ // the index knows one); unknown yet shows nothing.+ const when = closed+ ? (item.closedAt ?? item.updatedAt)+ : (item.lastActivityAt ?? item.updatedAt)return (<articleclassName={cn('group/card relative rounded-lg border p-3 transition-colors',- stale !== null+ dormant? 'border-foreground/15 hover:border-foreground/30 border-dashed bg-transparent': 'bg-panel hover:border-foreground/20 shadow-[0_1px_1px_0_rgb(20_19_17/0.03)]',)}@@ -494,13 +581,13 @@ export function Card({<span className="ml-auto flex shrink-0 items-center gap-2 pl-1"><WarningMark warnings={item.warnings} quiet />{item.unpublished ? <UnpublishedMark quiet /> : null}- {item.owner ? <Avatar person={item.owner} /> : null}+ {item.owner ? <OwnerMark owner={item.owner} /> : null}</span></div><h3className={cn('mt-2 line-clamp-2 text-sm leading-5 font-medium text-pretty',- (closed || stale !== null) && 'text-muted-foreground',+ (closed || dormant) && 'text-muted-foreground',)}><Link@@ -527,21 +614,10 @@ export function Card({</div>{children ? <div className="relative z-10">{children}</div> : null}<PullDots prs={item.pullRequests} />- {sessions ? (- <span- className="inline-flex items-center gap-1 tabular-nums"- title={plural(sessions, 'session')}- >- <MessagesSquare className="size-3.5" aria-hidden />- {sessions}- <span className="sr-only">- {sessions === 1 ? ' session' : ' sessions'}- </span>- </span>- ) : null}- {stale !== null || when ? (- <span className="shrink-0 tabular-nums" title={when ?? undefined}>- {stale !== null ? `no change in ${stale} days` : timeAgo(when)}+ <SessionDots sessions={item.sessions} />+ {when ? (+ <span className="shrink-0 tabular-nums" title={when}>+ {timeAgo(when)}</span>) : null}</div>diff --git a/web/src/managed-agents/work/Item.tsx b/web/src/managed-agents/work/Item.tsxindex 10eff71b..601c1170 100644--- a/web/src/managed-agents/work/Item.tsx+++ b/web/src/managed-agents/work/Item.tsx@@ -35,6 +35,7 @@ import {import {AttentionMark,Avatar,+ DERIVED_OWNER,PullDot,SectionTitle,Tag,@@ -253,6 +254,10 @@ function ItemHeader({ item }: { item: Item }) {<span className="text-foreground">{personName(item.owner)}</span>+ {/* Not in the doc: the author of its recent changes. */}+ {item.owner.source === 'derived' ? (+ <span>({DERIVED_OWNER.toLowerCase()})</span>+ ) : null}</>) : ('no owner'diff --git a/web/src/managed-agents/work/api.ts b/web/src/managed-agents/work/api.tsindex ccad0550..d7fb830e 100644--- a/web/src/managed-agents/work/api.ts+++ b/web/src/managed-agents/work/api.ts@@ -20,6 +20,16 @@ const PersonSchema = z.looseObject({})export type Person = z.infer<typeof PersonSchema>+// Who owns an item: the doc's `owner:` (declared), or else the author of its+// latest change that was not a bulk edit (derived, from recent commits).+const OwnerSchema = z.looseObject({+ email: z.string(),+ name: z.string().nullable(),+ id: z.string().nullable(),+ source: z.enum(['declared', 'derived']),+})+export type Owner = z.infer<typeof OwnerSchema>+export const RepositorySchema = z.looseObject({installationId: z.union([z.string(), z.number()]),owner: z.string(),@@ -79,7 +89,7 @@ export const ItemSchema = z.looseObject({title: z.string(),stateLine: z.string().nullable(),tags: z.array(z.string()),- owner: PersonSchema.nullable(),+ owner: OwnerSchema.nullable(),author: PersonSchema.nullable(),mine: z.boolean(),left: z.number().nullable(),@@ -91,6 +101,12 @@ export const ItemSchema = z.looseObject({unpublished: z.boolean(),// Null while the index has not read the doc's last commit yet.updatedAt: z.string().nullable(),+ // The doc's latest commit that was not a bulk edit (one touching more than+ // five items); null when the index has read none.+ lastActivityAt: z.string().nullable(),+ // Changed in the last 14 days, or a linked session is running or waiting:+ // the board shows active items and folds the rest under "Dormant".+ active: z.boolean(),createdAt: z.string().nullable(),// Both may be null on a closed item, when not known yet.closedAt: z.string().nullable(),@@ -119,6 +135,10 @@ const ItemResultSchema = z.looseObject({})export type ItemResult = z.infer<typeof ItemResultSchema>+const SessionItemsSchema = z.looseObject({+ items: z.array(ItemSchema),+})+const RevisionSchema = z.looseObject({sha: z.string(),url: z.string(),@@ -286,6 +306,16 @@ export function getHistory(number: number, cursor: string | undefined) {)}+/** The items a session worked on (its commits' `Session:` trailers). */+export function getSessionItems(sessionId: string) {+ return apiFetch(+ `${PREFIX}/sessions/${encodeURIComponent(sessionId)}/items`,+ undefined,+ SessionItemsSchema,+ '/api',+ ).then((r) => r.items)+}+// Every key starts with the organization so a switch never shows another// organization's items.export const workKeys = {@@ -296,6 +326,7 @@ export const workKeys = {closed: (org: string) => ['work', org, 'items', 'closed'] as const,item: (org: string, n: number) => ['work', org, 'item', n] as const,history: (org: string, n: number) => ['work', org, 'history', n] as const,+ session: (org: string, id: string) => ['work', org, 'session', id] as const,}/** The organization the keys are scoped to; '' before the user is known. */diff --git a/web/src/managed-agents/work/board.test.ts b/web/src/managed-agents/work/board.test.tsindex c25b4674..91acb0a5 100644--- a/web/src/managed-agents/work/board.test.ts+++ b/web/src/managed-agents/work/board.test.ts@@ -11,7 +11,7 @@ import {repositoryProblem,resolveAgainst,sessionStatusWord,- staleDays,+ splitDormant,} from './board'import { makeItem, minutesAgo, NOW } from './fixtures'@@ -125,12 +125,28 @@ describe('card wording', () => {expect(attentionLabel(makeItem(), ago)).toBeNull()})- it('marks an open card stale after two weeks without a change', () => {- expect(staleDays(makeItem({ updatedAt: minutesAgo(20 * DAY) }), NOW)).toBe(- 20,- )- expect(staleDays(makeItem({ updatedAt: minutesAgo(DAY) }), NOW)).toBeNull()- expect(staleDays(makeItem({ updatedAt: null }), NOW)).toBeNull()+ it('folds the cards the API calls inactive away from the active ones', () => {+ const { active, dormant } = splitDormant([+ makeItem({ number: 1 }),+ makeItem({ number: 2, active: false }),+ makeItem({ number: 3 }),+ ])+ expect(active.map((i) => i.number)).toEqual([1, 3])+ expect(dormant.map((i) => i.number)).toEqual([2])+ })++ it("orders by an item's own last change, not a bulk edit's", () => {+ const items = [+ // A bulk edit touched it a minute ago; its own change is a day old.+ makeItem({+ number: 1,+ updatedAt: minutesAgo(1),+ lastActivityAt: minutesAgo(DAY),+ }),+ makeItem({ number: 2, updatedAt: minutesAgo(60), lastActivityAt: null }),+ makeItem({ number: 3, updatedAt: null, lastActivityAt: null }),+ ]+ expect(inProgress(items).map((i) => i.number)).toEqual([2, 1, 3])})it('words a session status the way the sessions screens do', () => {diff --git a/web/src/managed-agents/work/board.ts b/web/src/managed-agents/work/board.tsindex a66a3c61..49bfba93 100644--- a/web/src/managed-agents/work/board.ts+++ b/web/src/managed-agents/work/board.ts@@ -14,7 +14,6 @@ export type Tab = 'mine' | 'everyone'// The board and the item page poll this often (tech design 3.11).export const OPEN_POLL_MS = 15_000-export const STALE_DAYS = 14export const CLOSED_RECENT_DAYS = 7const DAY = 86_400_000@@ -31,15 +30,15 @@ export function matches(item: Item, f: Filters): boolean {)}+// The change a card's time shows: its own (not a bulk edit) when known.+const changedAt = (i: Item) => i.lastActivityAt ?? i.updatedAt+// Newest change first; an item whose last change is not known yet goes last.-const latestFirst = (a: Item, b: Item) =>- a.updatedAt === b.updatedAt- ? 0- : a.updatedAt === null- ? 1- : b.updatedAt === null- ? -1- : b.updatedAt.localeCompare(a.updatedAt)+const latestFirst = (a: Item, b: Item) => {+ const x = changedAt(a)+ const y = changedAt(b)+ return x === y ? 0 : x === null ? 1 : y === null ? -1 : y.localeCompare(x)+}const needsYouFirst = (a: Item, b: Item) =>(a.attention?.state === 'needs_you' ? 0 : 1) -@@ -78,11 +77,19 @@ export function closedShown()}-/** Days since the last change, when that makes the card stale; else null. */-export function staleDays(item: Item, now = Date.now()): number | null {- if (item.stage !== 'open' || item.updatedAt === null) return null- const days = Math.floor((now - new Date(item.updatedAt).getTime()) / DAY)- return days >= STALE_DAYS ? days : null+/**+ * A lane's cards as the board shows them: the active ones, and the dormant+ * ones it folds away (the server's `active`: no change of their own in two+ * weeks and no session at work). A view, not a stage.+ */+export function splitDormant(items: Item[]): {+ active: Item[]+ dormant: Item[]+} {+ return {+ active: items.filter((i) => i.active),+ dormant: items.filter((i) => !i.active),+ }}/** The one attention line on a card, and whether it is the coloured one. */diff --git a/web/src/managed-agents/work/fixtures.ts b/web/src/managed-agents/work/fixtures.tsindex 7f73461f..20847783 100644--- a/web/src/managed-agents/work/fixtures.ts+++ b/web/src/managed-agents/work/fixtures.ts@@ -27,6 +27,10 @@ export function makeItem(over: Partial<Item> = {}): Item {sessions: [],unpublished: false,updatedAt: minutesAgo(60),+ // The item's own last change: its last change, unless a test says.+ lastActivityAt:+ over.updatedAt !== undefined ? over.updatedAt : minutesAgo(60),+ active: true,createdAt: null,closedAt: null,closedBy: null,diff --git a/web/src/managed-agents/work/parts.tsx b/web/src/managed-agents/work/parts.tsxindex 80eacf51..049d07e2 100644--- a/web/src/managed-agents/work/parts.tsx+++ b/web/src/managed-agents/work/parts.tsx@@ -1,23 +1,46 @@import type { ReactNode } from 'react'-import { AlertTriangle, CloudOff, GitPullRequest } from 'lucide-react'+import { Link } from 'react-router-dom'+import {+ AlertTriangle,+ CloudOff,+ GitPullRequest,+ MessagesSquare,+} from 'lucide-react'import { cn } from '@/lib/utils'+import { StatusDot } from '../computer-sessions/parts'import { timeAgo } from '../computer-sessions/transcript'-import type { Item, Person, PullRequest, PullState } from './api'-import { attentionLabel, personName, pullLabel, pullStateWord } from './board'+import type {+ Item,+ ItemSession,+ Owner,+ Person,+ PullRequest,+ PullState,+} from './api'+import {+ attentionLabel,+ personName,+ pullLabel,+ pullStateWord,+ sessionStatusWord,+} from './board'// Small pieces shared by the board and the item page.export function Avatar({person,+ title,className,}: {person: Person+ // The hover text; the name by default, null for none (the parent has it).+ title?: string | nullclassName?: string}) {const name = personName(person)return (<span- title={name}+ title={title === null ? undefined : (title ?? name)}className={cn('bg-secondary text-muted-foreground inline-flex size-5 shrink-0 items-center justify-center rounded-full text-[10px] font-medium uppercase',className,@@ -28,6 +51,68 @@ export function Avatar({)}+// Said on hover over an owner the doc does not name.+export const DERIVED_OWNER = 'From recent commits'++/**+ * The owner on a card: initial and name. One the doc does not declare, taken+ * from its recent commits, is quieter.+ */+export function OwnerMark({ owner }: { owner: Owner }) {+ const derived = owner.source === 'derived'+ const name = personName(owner)+ return (+ <span+ title={derived ? `${name} · ${DERIVED_OWNER}` : name}+ className={cn(+ 'inline-flex min-w-0 items-center gap-1.5',+ derived ? 'text-muted-foreground/80' : 'text-foreground/80',+ )}+ >+ <Avatar+ person={owner}+ title={null}+ className={cn(+ derived &&+ 'text-muted-foreground/80 border-muted-foreground/40 border border-dashed bg-transparent',+ )}+ />+ <span className="max-w-28 truncate">{name}</span>+ {derived ? <span className="sr-only">, {DERIVED_OWNER}</span> : null}+ </span>+ )+}++/** One dot per linked session, each a link to it; title and state on hover. */+export function SessionDots({ sessions }: { sessions: ItemSession[] }) {+ if (!sessions.length) return null+ return (+ <span className="inline-flex items-center gap-1">+ <MessagesSquare className="size-3.5" aria-hidden />+ {sessions.map((s) => {+ const label = [+ s.title || 'Untitled session',+ s.ownerName,+ sessionStatusWord(s.status),+ ]+ .filter(Boolean)+ .join(' · ')+ return (+ <Link+ key={s.id}+ to={`/computer/sessions/${s.id}`}+ title={label}+ aria-label={`Session: ${label}`}+ className="relative z-10 -m-0.5 inline-flex p-0.5 hover:opacity-70"+ >+ <StatusDot status={s.status} className="size-2" />+ </Link>+ )+ })}+ </span>+ )+}+export function Tag({tag,onClick,diff --git a/web/src/managed-agents/work/screens.test.tsx b/web/src/managed-agents/work/screens.test.tsxindex 56b121f1..8095707a 100644--- a/web/src/managed-agents/work/screens.test.tsx+++ b/web/src/managed-agents/work/screens.test.tsx@@ -341,6 +341,81 @@ describe('board', () => {expect(done.textContent).not.toContain('Closed by')})+ it('folds dormant cards under a quiet toggle, per lane', async () => {+ workApi.getOpenItems.mockResolvedValue(+ openPage([+ makeItem({ number: 1, title: 'Active' }),+ makeItem({ number: 2, title: 'Quiet one', active: false }),+ makeItem({ number: 3, title: 'Quiet two', active: false }),+ makeItem({+ number: 4,+ title: 'Quiet, done',+ active: false,+ readyToClose: true,+ }),+ ]),+ )+ await render('/computer/work?tab=everyone')+ expect(titles(column('In progress'))).toEqual(['Active'])+ expect(column('In progress').querySelector('h2')?.textContent).toContain(+ '1',+ )+ const toggle = [...column('In progress').querySelectorAll('button')].find(+ (b) => b.textContent === 'Dormant(2)',+ )+ expect(toggle?.getAttribute('aria-expanded')).toBe('false')+ expect(titles(column('Ready to close'))).toEqual([])+ expect(column('Ready to close').textContent).toContain('Dormant(1)')+ click(toggle)+ await settle()+ expect(titles(column('In progress'))).toEqual([+ 'Active',+ 'Quiet one',+ 'Quiet two',+ ])+ // The other lane stays folded.+ expect(titles(column('Ready to close'))).toEqual([])+ })++ it("shows the owner by name, quieter when it comes from commits, and links the item's sessions", async () => {+ workApi.getOpenItems.mockResolvedValue(+ openPage([+ makeItem({+ number: 1,+ title: 'Declared',+ owner: {+ email: '[email protected]',+ name: 'Maya Chen',+ id: 'usr_2',+ source: 'declared',+ },+ sessions: [+ { id: 'cs_7', title: 'Fix it', ownerName: 'Maya', status: 'idle' },+ ],+ }),+ makeItem({+ number: 2,+ title: 'Derived',+ owner: {+ email: '[email protected]',+ name: 'Sam',+ id: null,+ source: 'derived',+ },+ }),+ ]),+ )+ await render('/computer/work?tab=everyone')+ const cards = column('In progress').querySelectorAll('article')+ expect(cards[0].textContent).toContain('Maya Chen')+ expect(cards[0].querySelector('[title="Maya Chen"]')).not.toBeNull()+ expect(+ cards[1].querySelector('[title="Sam · From recent commits"]'),+ ).not.toBeNull()+ const link = cards[0].querySelector('a[href="/computer/sessions/cs_7"]')+ expect(link?.getAttribute('title')).toBe('Fix it · Maya · idle')+ })+it('offers no Close or Reopen yet', async () => {workApi.getOpenItems.mockResolvedValue(openPage(items))await render('/computer/work')@@ -356,7 +431,12 @@ describe('item page', () => {const item = makeItem({number: 12,title: 'Usage billing',- owner: { email: '[email protected]', name: 'Igor', id: 'usr_1' },+ owner: {+ email: '[email protected]',+ name: 'Igor',+ id: 'usr_1',+ source: 'declared',+ },author: { email: '[email protected]', name: 'Maya', id: null },tags: ['billing'],sessions: [@@ -390,6 +470,17 @@ describe('item page', () => {expect(workApi.getHistory).not.toHaveBeenCalled()})+ it('says when the owner comes from recent commits', async () => {+ workApi.getItem.mockResolvedValue({+ item: { ...item, owner: { ...item.owner!, source: 'derived' } },+ body: 'x',+ })+ await render('/computer/work/12')+ expect(container.querySelector('header')?.textContent).toContain(+ 'Igor(from recent commits)',+ )+ })+it('says when an item has no owner', async () => {workApi.getItem.mockResolvedValue({item: { ...item, owner: null },