Skip to content

An open-source, faster Devin alternative

TypeScript

web: updatedAt, closedAt and closedBy may be unknown: last in order, no time shown, just "Closed"

Igor Zalutski via Computer2d20e582a58b
diff --git a/web/src/api/mock-work.ts b/web/src/api/mock-work.ts
index b9091de7..f59fa0b7 100644
--- a/web/src/api/mock-work.ts
+++ b/web/src/api/mock-work.ts
@@ -193,8 +193,10 @@ const open: Json[] = [
author: priya,
left: 6,
}),
+ // The index has not read its last commit yet: no time on the card.
item(31, 'Look into the flaky end-to-end test', {
updated: 2 * D,
+ updatedAt: null,
stateLine: null,
owner: null,
author: sam,
@@ -273,7 +275,8 @@ const closed: Json[] = [
tags: ['billing'],
owner: sam,
left: 0,
- closedAt: ago(30 * D),
+ // Closed, but when and by whom is not known yet: just "Closed".
+ closedAt: null,
closedBy: null,
}),
]
@@ -322,7 +325,7 @@ const revisions = (it: Json) => [
{
sha: '9f2c1a7e4b3d2c1a0f9e8d7c6b5a4f3e2d1c0b9a',
url: 'https://github.com/acme/knowledge/commit/9f2c1a7',
- at: String(it.updatedAt),
+ at: (it.updatedAt as string | null) ?? ago(H),
authorName: 'Computer for Igor',
summary: 'Record the price-table question; metering merged',
sessionId: S1,
diff --git a/web/src/managed-agents/work/Board.tsx b/web/src/managed-agents/work/Board.tsx
index b2a6f75b..b6dc774b 100644
--- a/web/src/managed-agents/work/Board.tsx
+++ b/web/src/managed-agents/work/Board.tsx
@@ -487,6 +487,8 @@ export function Card({
const 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
return (
<article
className={cn(
@@ -557,13 +559,11 @@ export function Card({
</span>
</span>
) : null}
- <span className="shrink-0 tabular-nums" title={item.updatedAt}>
- {stale !== null
- ? `no change in ${stale} days`
- : timeAgo(
- closed ? (item.closedAt ?? item.updatedAt) : item.updatedAt,
- )}
- </span>
+ {stale !== null || when ? (
+ <span className="shrink-0 tabular-nums" title={when ?? undefined}>
+ {stale !== null ? `no change in ${stale} days` : timeAgo(when)}
+ </span>
+ ) : null}
</div>
</article>
)
diff --git a/web/src/managed-agents/work/Item.tsx b/web/src/managed-agents/work/Item.tsx
index c1242c9b..8f301b7b 100644
--- a/web/src/managed-agents/work/Item.tsx
+++ b/web/src/managed-agents/work/Item.tsx
@@ -191,6 +191,8 @@ function Breadcrumb({ number }: { number: number | null }) {
function ItemHeader({ item }: { item: Item }) {
const closed = item.stage === 'closed'
+ // Null when not known yet: then no time is shown.
+ const when = closed ? (item.closedAt ?? item.updatedAt) : item.updatedAt
return (
<header className="border-b pb-5">
<div className="flex flex-wrap items-start gap-x-6 gap-y-2">
@@ -246,14 +248,11 @@ function ItemHeader({ item }: { item: Item }) {
{item.closedBy ? `closed by ${item.closedBy}` : 'closed'}
</span>
) : null}
- <span
- title={(closed ? item.closedAt : null) ?? item.updatedAt}
- className="tabular-nums"
- >
- {closed
- ? timeAgo(item.closedAt ?? item.updatedAt)
- : `changed ${timeAgo(item.updatedAt)}`}
- </span>
+ {when ? (
+ <span title={when} className="tabular-nums">
+ {closed ? timeAgo(when) : `changed ${timeAgo(when)}`}
+ </span>
+ ) : null}
{!closed && item.attention ? <AttentionMark item={item} /> : null}
{item.warnings.length ? (
<span className="inline-flex items-center gap-1">
diff --git a/web/src/managed-agents/work/api.ts b/web/src/managed-agents/work/api.ts
index 2f9da90b..1cad0b7a 100644
--- a/web/src/managed-agents/work/api.ts
+++ b/web/src/managed-agents/work/api.ts
@@ -81,8 +81,10 @@ export const ItemSchema = z.looseObject({
attention: AttentionSchema.nullable(),
sessions: z.array(ItemSessionSchema),
unpublished: z.boolean(),
- updatedAt: z.string(),
+ // Null while the index has not read the doc's last commit yet.
+ updatedAt: z.string().nullable(),
createdAt: z.string().nullable(),
+ // Both may be null on a closed item, when not known yet.
closedAt: z.string().nullable(),
closedBy: z.string().nullable(),
})
diff --git a/web/src/managed-agents/work/board.test.ts b/web/src/managed-agents/work/board.test.ts
index 767ebd33..404180f9 100644
--- a/web/src/managed-agents/work/board.test.ts
+++ b/web/src/managed-agents/work/board.test.ts
@@ -44,6 +44,22 @@ describe('board columns', () => {
expect(inProgress(items).map((i) => i.number)).toEqual([2, 3, 1])
})
+ it('puts an item with no known change last within its group', () => {
+ const needsYou = {
+ state: 'needs_you' as const,
+ name: null,
+ since: minutesAgo(1),
+ }
+ const items = [
+ makeItem({ number: 1, updatedAt: null }),
+ makeItem({ number: 2, updatedAt: minutesAgo(500) }),
+ makeItem({ number: 3, updatedAt: null, attention: needsYou }),
+ makeItem({ number: 4, updatedAt: minutesAgo(5), attention: needsYou }),
+ makeItem({ number: 5, updatedAt: minutesAgo(1) }),
+ ]
+ expect(inProgress(items).map((i) => i.number)).toEqual([4, 3, 5, 2, 1])
+ })
+
it('shows closed items of the last seven days unless older are asked for', () => {
const items = [
makeItem({ number: 1, stage: 'closed', closedAt: minutesAgo(2 * DAY) }),
@@ -113,6 +129,7 @@ describe('card wording', () => {
20,
)
expect(staleDays(makeItem({ updatedAt: minutesAgo(DAY) }), NOW)).toBeNull()
+ expect(staleDays(makeItem({ updatedAt: null }), NOW)).toBeNull()
})
it('names a pull request by its number', () => {
diff --git a/web/src/managed-agents/work/board.ts b/web/src/managed-agents/work/board.ts
index 354d9eac..e401ed2e 100644
--- a/web/src/managed-agents/work/board.ts
+++ b/web/src/managed-agents/work/board.ts
@@ -25,12 +25,24 @@ export function matches(item: Item, f: Filters): boolean {
)
}
+// 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 needsYouFirst = (a: Item, b: Item) =>
(a.attention?.state === 'needs_you' ? 0 : 1) -
- (b.attention?.state === 'needs_you' ? 0 : 1) ||
- b.updatedAt.localeCompare(a.updatedAt)
+ (b.attention?.state === 'needs_you' ? 0 : 1) || latestFirst(a, b)
-/** In progress: the cards that need the viewer first, then by last change. */
+/**
+ * In progress: the cards that need the viewer first, then by last change
+ * (unknown last, within each group).
+ */
export function inProgress(items: Item[]): Item[] {
return items
.filter((i) => i.stage === 'open' && !i.readyToClose)
@@ -62,7 +74,7 @@ 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') return 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
}
diff --git a/web/src/managed-agents/work/screens.test.tsx b/web/src/managed-agents/work/screens.test.tsx
index 3f5392cc..19c21ef7 100644
--- a/web/src/managed-agents/work/screens.test.tsx
+++ b/web/src/managed-agents/work/screens.test.tsx
@@ -267,6 +267,40 @@ describe('board', () => {
).not.toBeNull()
})
+ it('shows no time where the last change or the closing is not known', async () => {
+ workApi.getOpenItems.mockResolvedValue(
+ openPage([
+ makeItem({
+ number: 7,
+ title: 'Unknown age',
+ mine: true,
+ updatedAt: null,
+ }),
+ ]),
+ )
+ workApi.getClosedItems.mockResolvedValue({
+ items: [
+ makeItem({
+ number: 8,
+ title: 'Closed, details unknown',
+ stage: 'closed',
+ mine: true,
+ updatedAt: null,
+ closedAt: null,
+ closedBy: null,
+ }),
+ ],
+ nextCursor: null,
+ })
+ await render('/computer/work?older=1')
+ const open = column('In progress').querySelector('article')!
+ expect(open.textContent).not.toMatch(/no change in|\d+d|Jan/)
+ expect(open.querySelector('[title]')).toBeNull()
+ const done = column('Closed').querySelector('article')!
+ expect(done.textContent).toContain('Closed')
+ expect(done.textContent).not.toContain('Closed by')
+ })
+
it('offers no Close or Reopen yet', async () => {
workApi.getOpenItems.mockResolvedValue(openPage(items))
await render('/computer/work')
@@ -324,6 +358,36 @@ describe('item page', () => {
expect(container.querySelector('header')?.textContent).toContain('no owner')
})
+ it('shows just "closed" when who and when are not known', async () => {
+ workApi.getItem.mockResolvedValue({
+ item: {
+ ...item,
+ stage: 'closed',
+ updatedAt: null,
+ closedAt: null,
+ closedBy: null,
+ },
+ body: 'x',
+ })
+ await render('/computer/work/12')
+ const header = container.querySelector('header')!.textContent
+ expect(header).toContain('Closed')
+ expect(header).toContain('closed')
+ expect(header).not.toContain('closed by')
+ expect(header).not.toContain('changed')
+ })
+
+ it('shows no change time on an open item before it is known', async () => {
+ workApi.getItem.mockResolvedValue({
+ item: { ...item, updatedAt: null },
+ body: 'x',
+ })
+ await render('/computer/work/12')
+ expect(container.querySelector('header')!.textContent).not.toContain(
+ 'changed',
+ )
+ })
+
it('lists the changes on the History tab', async () => {
workApi.getItem.mockResolvedValue({ item, body: 'x' })
workApi.getHistory.mockResolvedValue({